[25185] in Perl-Users-Digest
Perl-Users Digest, Issue: 7434 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 21 14:05:36 2004
Date: Sun, 21 Nov 2004 11:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 21 Nov 2004 Volume: 10 Number: 7434
Today's topics:
"Undefined subroutine" <haaedxxdpaxqo@mailinator.com>
Re: "Undefined subroutine" <jkeen_via_google@yahoo.com>
Re: Copying a folder (Jim)
Re: CTRL-Z on Win32 <see@sig.invalid>
Dat files help hope@hope.com
Re: Dat files help <spamtrap@dot-app.org>
Re: Easier web programming language: PERL or PHP? (T. Jansma)
FAQ 3.31: When I tried to run my script, I got this mes <comdog@panix.com>
Re: First Perl Program <bik.mido@tiscalinet.it>
Re: keep the reference pointer of an object <perl@my-header.org>
Re: keep the reference pointer of an object nobull@mail.com
Re: keep the reference pointer of an object <sam.wun@authtec.net>
Re: keep the reference pointer of an object <tadmc@augustmail.com>
Re: keep the reference pointer of an object <gnari@simnet.is>
Re: Not Initializing Variables Correctly? nobull@mail.com
Re: Not Initializing Variables Correctly? <see@sig.invalid>
Perl Test - Any examples on web <stephen.adam@ntlworld.com>
Re: PLEASE HELP! Perl script does not work! (Gandu)
Re: PLEASE HELP! Perl script does not work! (Gandu)
Storing a substitution (similar to qr()) <apollock11@hotmail.com>
Re: Storing a substitution (similar to qr()) <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 21 Nov 2004 19:48:26 +0100
From: "B H" <haaedxxdpaxqo@mailinator.com>
Subject: "Undefined subroutine"
Message-Id: <Yp5od.8974$rh1.230722@news2.e.nsc.no>
Trying to use an "old" script which I have not written myself. It has worked
previously
under installation on other machines (with possible older versions of Perl).
The problem is that I do not remember all the modules I loaded and which
modifications I
did in order to make it work last time.
I have used CPAN and made and installed URI (at least I think I did it), but
I do not
know if this is enough.
I still get the following error:
===
Undefined subroutine &URI::URL called at /home/c4n/bin/<scriptname> line
488.
Line 488:
my $urlobj = new URI::URL( $values[$i], $self->{'url'} );
===
I am not experienced in Perl, so maybe the error is obvious. But now I am
tired of banging my head against the wall.
Could there be problems related to a possible change of version of Perl
since
I last used this script?
Can I have done something wrong during CPAN-download ( I did make, test
and install)?
Something else?
Borge
------------------------------
Date: Sun, 21 Nov 2004 18:59:29 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: "Undefined subroutine"
Message-Id: <lA5od.8180$Vy.6150@trndny06>
B H wrote:
> Trying to use an "old" script which I have not written myself. It has worked
> previously
> under installation on other machines (with possible older versions of Perl).
> The problem is that I do not remember all the modules I loaded and which
> modifications I
> did in order to make it work last time.
> I have used CPAN and made and installed URI (at least I think I did it), but
> I do not
> know if this is enough.
> I still get the following error:
> ===
> Undefined subroutine &URI::URL called at /home/c4n/bin/<scriptname> line
> 488.
>
> Line 488:
>
> my $urlobj = new URI::URL( $values[$i], $self->{'url'} );
> ===
Assuming you have correctly installed the latest version of URI, call
perldoc URI
This shows the documentation. I infer from a note in the
"Authors/Acknowledgments" section that this module supercedes the older
URI::URL module. I also fail to find a &URL in the current version. So
that explains why you get the "undefined subroutine" error.
I recommend studying the documentation for URI and and recoding your
script as needed.
Jim Keenan
------------------------------
Date: 21 Nov 2004 10:48:00 -0800
From: garvey_jim@yahoo.com (Jim)
Subject: Re: Copying a folder
Message-Id: <3327e074.0411211048.3df2782@posting.google.com>
Thanks for the help.
I can only access the information viz http. ftp will not work. wget
is not supported in the dos cmd window.
------------------------------
Date: Sun, 21 Nov 2004 11:49:38 -0500
From: Bob Walton <see@sig.invalid>
Subject: Re: CTRL-Z on Win32
Message-Id: <41a0c4b4$1_2@127.0.0.1>
Bill Smith wrote:
> "Bob Walton" <see@sig.invalid> wrote in message
> news:41a007db$1_4@127.0.0.1...
>
>>Bill Smith wrote:
...
>
> You certainly clarified a secondary issue. The symptom that I described
> can only happen if the CTRL-Z is the first character of the first line
> after the last string.
>
>
So what you are saying is that on your system you get something other
than the below when the sequence of keystrokes to the program's input is
qwer<enter>asdf<enter>zxcv<enter><control-z><enter>
:
D:\junk>perl -e "print reverse <>"
qwer
asdf
zxcv
^Z
zxcv
asdf
qwer
D:\junk>
when you run that one-liner? Could you post exactly what you do get?
The above was Windoze XP Home sp2, Perl 5.8.4, AS build 810. If Windoze
ME doesn't work right, you might try upgrading Windoze -- Windoze ME is
pretty obsolescent any more (not that it was much good in the first
place).
It seems like I recall some issue like you describe with Windoze 98SE,
but I can no longer test that. I seem to recall it had something to do
with Windoze overwriting the last line of output with a blank line or
maybe the prompt (but only when a control-Z had been used), and that it
could be fixed by outputing an extra blank line to the console at the
end of your program. Try that.
The other alternative would be to simply read your data from a file.
Just key it into a text editor, save it, and use input redirection to
pick it from the file. Console input is so clunky, anyway -- you have
to redo it each time you test your program.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sun, 21 Nov 2004 12:10:43 GMT
From: hope@hope.com
Subject: Dat files help
Message-Id: <hi01q0he2cphu125d6b46pvjqcfs7tbj8v@4ax.com>
Hi
First I'm new to perl
I have done a load of searches on the net to find out how to do this but came up with nothing
What I have is this
1....I have a load of dat files in a folder called users this is in the cgi folder like
c:\apache\apache2\cgi-bin\data\users\1234.dat 5678.dat etc
2.....Inside each of these dat files I have information like
password
email
FullName
Street Address
City
Country
Zip
Phone
3.....Now what I want to do is fetch the above info out of the dat files and do one of two things
1......Put in a excel l file OR
2......Make a text/csv file with information all on one line with it separated by a "," I then can import that into a excel my self
If you could give me some pointers on how to do this OR point me in the right direction to where I could get some examples please
My Os is
Win XP Pro
Apache
Perl
As always, any and all help is greatly appreciated.
Thank you in advance.
John
------------------------------
Date: Sun, 21 Nov 2004 07:27:46 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Dat files help
Message-Id: <lb-dncoF1pMKFD3cRVn-1w@adelphia.com>
hope@hope.com wrote:
> First I'm new to perl
First, have you read the posting guidelines that are posted here
frequently? Are you familiar with the Perl FAQ, which you can read with
"perldoc perlfaq" and search with "perldoc -q search_term"?
> 3.....Now what I want to do is fetch the above info out of the dat
The best way to do that will depend largely on how that info is
formatted. There are lots of modules on CPAN to read files of various
formats - you might want to search for the name of the format you're
using (JPEG, CSV, etc.), or for the name of the application that created
these files (Word, dBase, etc.) at <http://search.cpan.org>.
If the format is unique and/or there's no appropriate module, there's
always the old standby - open() the file and read raw data. Reading from
files should be covered fairly early in any decent book or tutorial -
see <http://learn.perl.org>.
> 1......Put in a excel l file OR
Have a look at Spreadsheet::WriteExcel on CPAN.
> 2......Make a text/csv file
Have a look at Text::CSV on CPAN.
Or, search for "Excel" and "CSV" on CPAN - there are several related
modules.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 21 Nov 2004 03:38:00 -0800
From: naecke@gmx.net (T. Jansma)
Subject: Re: Easier web programming language: PERL or PHP?
Message-Id: <a5ca6d6c.0411210338.478fd345@posting.google.com>
Alan Mead <amead@comcast.net> wrote in message news:<pan.2004.11.20.05.08.46.472762@comcast.net>...
> > I would to study a web programming language to create a script that,
> > given
>
> Perl would be the best choice here because it was designed with postage
> and packaging in mind. (That's what the 'P' in Perl stands for).
Oh, haha, no, crazy coot... PHP is best suited for this, PHP stands
for:
Package Handling & Pricing
Imagine that, a whole programming language designed exactly for this
problem, wow! :)
CU!
Tim.
------------------------------
Date: Sun, 21 Nov 2004 17:03:02 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 3.31: When I tried to run my script, I got this message. What does it mean?
Message-Id: <cnqho6$4bg$1@reader1.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
3.31: When I tried to run my script, I got this message. What does it mean?
A complete list of Perl's error messages and warnings with explanatory
text can be found in perldiag. You can also use the splain program
(distributed with Perl) to explain the error messages:
perl program 2>diag.out
splain [-v] [-p] diag.out
or change your program to explain the messages for you:
use diagnostics;
or
use diagnostics -verbose;
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Sun, 21 Nov 2004 18:14:11 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: First Perl Program
Message-Id: <tei1q0pqdsvn4g0l7pkm3svflgfc39fh44@4ax.com>
On 20 Nov 2004 09:03:09 -0800, jl_post@hotmail.com (J. Romano) wrote:
>lines. However, I recomment adding a comment line or two showing an
>example of what type of line you have found as the first line of the
>"if" block. In other words, I recommend making your "if" block look
>like this:
>
> # Find lines defining points (Type=116)
> if ($line =~ /^116/) {
> # Now $line should look something like this:
> # 116,blue,$19.95,45.5N,63.0W
> @parts = split (",",$line);
> ...
> }
Maybe it's just me, but I *partly* disagree: I think that generally
speaking clobbering code with unnecessary cmts degradates readability
rather than improving it.
In other words well written code must be self-explanatory and only
less than obvious contructs should require explicative cmts.
However in this case what you suggest may be legitimate for the format
of input data may not be obvious, but then in that case I'd rather
just include some info (either cmt or pod) about it and about what the
program is supposed to do with it say at the top of the script itself.
>You can also add a comment line that shows an example of what could be
>printed out, like this:
>
> # Write out point x,y,z location.
> # Example output: blue $19.95 45.5N
> print OUTF "@parts[1..3]\n";
Well, in this case IMHO, provided that that kind of info has already
been provided above, such a comment would only be redundant and
disturbing.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sun, 21 Nov 2004 12:34:24 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: keep the reference pointer of an object
Message-Id: <sdu0q0dbc1gav6l6aiomc8aqb9q8b501co@4ax.com>
X-Ftn-To: sam
sam <sam.wun@authtec.net> wrote:
>How can I login Cyrus once and keep its returned reference for another
>.cgi file used? (I won't keep plaintext password in perl or
>configuration file either, so if imap is not login by Cyrus admin, user
>need to login Cyrus admin account first).
>
>For example, if I have already invoked $imap = &imap_connect() in the
>index.cgi file, another cgi file (set_quota.cgi) no need to call the
>method imap_connect() again, instead, it will somehow use the reference
>of imap created in the index.cgi file and just call $imap->setquota().
You can make your objects persistent with Data::Dumper or FreezeThaw but
their usability depend on the object class. If your object uses socket
handle, you might want to use some different approach.
http://search.cpan.org/~ilyaz/FreezeThaw-0.43/FreezeThaw.pm
--
Matija
------------------------------
Date: 21 Nov 2004 05:25:19 -0800
From: nobull@mail.com
Subject: Re: keep the reference pointer of an object
Message-Id: <4dafc536.0411210525.69bd81f4@posting.google.com>
[sorry if an earlier draft of this appears too, my ISP's NNTP spool
appears to be accepting posts but then they don't appear even in the
local spool ]
sam wrote:
> I would like to do something like C in Perl. Sorry, I m not expert in Perl.
OK so if you claim you know how you'd do it in C then ptray tell, how
would you make an in-memory object (including an open soocket
connection) persist from one instance of a CGI process to another if
you were writing your CGI programs in C?
Before you continue please recite 10 times "Perl is not CGI, CGI is
not Perl". :-)
> I m writng a webmin module that manage the Cyrus email accounts.
> But every time when need to change the Cyrus user account info, I need
> to use the Cyrus::IMAP::Admin->new() method login Cyrus first.
>
> How can I login Cyrus once and keep its returned reference for
> another .cgi file used?
In general you can't make in-memory entities in Perl persist from one
process to another unless they provide a means to serialise themselves
to a string/file. (This is the same as C and most other languages).
> (I won't keep plaintext password in perl or configuration file either, so
> if imap is not login by Cyrus admin, user need to login Cyrus admin
> account first).
You want to maintain the Cyrus credentials as some sort of session
persitant data. There are three ways to maintain session data in web
programming (in the URL, in a hidden field, or in a cookie). You can
also use a small bit of session data stored using one of these three
to identify larger session data stored in a database or filesystem.
This is not specific to Perl or CGI - it applies to server-side web
programming in general and hense equally to other languages and other
ways of interacting with the web server.
For a example of implementing web sessions in Perl and CGI you could
do worse than look for a Perl module with 'CGI' and 'Session' in its
name.
> For example, if I have already invoked $imap = &imap_connect() in
> the index.cgi file,
You should not use the special &-prefixed subroutine call notation
unless you know what it does and want those semantics.
> another cgi file (set_quota.cgi) no need to call the method
> imap_connect() again, instead, it will somehow use the reference
> of imap created in the index.cgi file and just call $imap->setquota().
As I said above, in general you can't make in-memory entities in C,
Perl and most other languages persist from one process to another.
(This is particularly true of entities that embody a connection to an
external resource).
> Not sure if use Global declaration is a good idea. I don't want this
> reference to be "boardcast". I found command ENV is a way to get the
> value of the enviornment variable, but don't think this is a secure
> way to get the reference of the object in this case.
Niether a global variable nor environment variable set in one CGI
process would propagate to another CGI process. And even if it did[1]
then it would not be per-session. Once one person had "logged in"
anyone anywhere could use the connection.
[1] As, say, they would if you replaced CGI with mod_perl using a
single Perl instance. (Not something you'd usually do).
------------------------------
Date: Sun, 21 Nov 2004 22:06:28 +0800
From: sam <sam.wun@authtec.net>
Subject: Re: keep the reference pointer of an object
Message-Id: <cnq8uo$1osc$1@news.hgc.com.hk>
nobull@mail.com wrote:
>
>>(I won't keep plaintext password in perl or configuration file either, so
>>if imap is not login by Cyrus admin, user need to login Cyrus admin
>>account first).
>
>
> You want to maintain the Cyrus credentials as some sort of session
> persitant data. There are three ways to maintain session data in web
> programming (in the URL, in a hidden field, or in a cookie). You can
> also use a small bit of session data stored using one of these three
> to identify larger session data stored in a database or filesystem.
>
In this case I think I will keep the plaintext of the password as a
hidden field. Actually this is only my concern, I worried the password
will be somehow "seen" by the client. Is there any example I can follow
to make a hidden value to be passed around, and probbably with cookie to
be safer?
Thanks
Sam
> This is not specific to Perl or CGI - it applies to server-side web
> programming in general and hense equally to other languages and other
> ways of interacting with the web server.
>
> For a example of implementing web sessions in Perl and CGI you could
> do worse than look for a Perl module with 'CGI' and 'Session' in its
> name.
>
------------------------------
Date: Sun, 21 Nov 2004 09:24:34 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: keep the reference pointer of an object
Message-Id: <slrncq1cpi.oko.tadmc@magna.augustmail.com>
sam <sam.wun@authtec.net> wrote:
> nobull@mail.com wrote:
>> There are three ways to maintain session data in web
>> programming (in the URL, in a hidden field, or in a cookie).
> In this case I think I will keep the plaintext of the password as a
> hidden field.
You should realize that a "hidden" field is not really hidden...
> Actually this is only my concern,
Good, but you haven't solved the problem yet, keep thinking about it.
> I worried the password
> will be somehow "seen" by the client.
View -> Page Source
then
Edit -> Find in Page (enter "hidden")
there is the password for all to see.
All that is "hidden" is the user interface corresponding to that
value, that is, a "normal" user that only knows how to point
and click cannot change its value. The value is easy to see
and easy to spoof, it is not a "security" mechanism, it is
a "state" mechanism.
You will still need to work out a way to handle the "security"
part of your problem.
(and we don't solve non-Perl problems in the Perl newsgroup.)
>> For a example of implementing web sessions in Perl and CGI you could
>> do worse than look for a Perl module with 'CGI' and 'Session' in its
>> name.
Did you follow that suggestion yet?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 21 Nov 2004 16:43:42 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: keep the reference pointer of an object
Message-Id: <cnqgf0$g8$1@news.simnet.is>
"sam" <sam.wun@authtec.net> wrote in message
news:cnq8uo$1osc$1@news.hgc.com.hk...
> nobull@mail.com wrote:
>
> >
> >
> > You want to maintain the Cyrus credentials as some sort of session
> > persitant data. There are three ways to maintain session data in web
> > programming (in the URL, in a hidden field, or in a cookie). You can
> > also use a small bit of session data stored using one of these three
> > to identify larger session data stored in a database or filesystem.
> >
> In this case I think I will keep the plaintext of the password as a
> hidden field.
no please do not do that. keep a session key in your hidden field,
and keep the password in persistent session data.
> Actually this is only my concern, I worried the password
> will be somehow "seen" by the client.
hidden fields can easily be 'seen'
> Is there any example I can follow
> to make a hidden value to be passed around, and probbably with cookie to
> be safer?
cookies are not safer, and only marginally more difficult to be 'seen'
> >
> > For a example of implementing web sessions in Perl and CGI you could
> > do worse than look for a Perl module with 'CGI' and 'Session' in its
> > name.
good advice
gnari
------------------------------
Date: 21 Nov 2004 05:07:45 -0800
From: nobull@mail.com
Subject: Re: Not Initializing Variables Correctly?
Message-Id: <4dafc536.0411210507.1f3a4b6d@posting.google.com>
Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrncpqunj.6aa.tadmc@magna.augustmail.com>...
> Bob Walton <see@sig.invalid> wrote:
>
> > That seems like reasonable behavior: if the
> > cell has no value, it generates undef in Perl.
>
>
> I would say that representing an empty spreadsheet cell as
> an empty string would be ever so much more reasonable. :-)
>
> I'd reserve undef for cells outside the 2-D limits of the spreadsheet.
Now, I can see a smiley in there so I think you are joking. I _hope_
you are joking. On first reading I did not see the smiley there. I
fear that some others reading this may not realise it's a joke.
So just to be clear. Tad you were joking, weren't you?
------------------------------
Date: Sun, 21 Nov 2004 12:14:21 -0500
From: Bob Walton <see@sig.invalid>
Subject: Re: Not Initializing Variables Correctly?
Message-Id: <41a0ca80$1_3@127.0.0.1>
Tad McClellan wrote:
> Bob Walton <see@sig.invalid> wrote:
>
>
>>That seems like reasonable behavior: if the
>>cell has no value, it generates undef in Perl.
>
>
>
> I would say that representing an empty spreadsheet cell as
> an empty string would be ever so much more reasonable. :-)
>
> I'd reserve undef for cells outside the 2-D limits of the spreadsheet.
>
>
Hmmmm...I see that an Excel cell can contain an empty string, in which
case the cell is not empty. To distinguish empty cells from those
containing the empty string, the use of undef for empty cells still
seems good to me.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sun, 21 Nov 2004 17:02:30 GMT
From: "Stephen Adam" <stephen.adam@ntlworld.com>
Subject: Perl Test - Any examples on web
Message-Id: <GS3od.78$W91.15@newsfe5-win.ntli.net>
Hi there,
I've got an interview for a junior web developer role and they will be
testing my Perl skills in the interview. I was just wondering if there was
an online resource for example tests of varying levels for Perl and any
other languages.
Thanks
Steve
------------------------------
Date: 21 Nov 2004 08:36:58 -0800
From: cpptutor2000@yahoo.com (Gandu)
Subject: Re: PLEASE HELP! Perl script does not work!
Message-Id: <3c7c9804.0411210836.47791494@posting.google.com>
Dear Sir,
Thank you very much for this very helpful hint.
Andrew Tkachenko <and11@rol.ru> wrote in message news:<cno24g$hbg$1@news.rol.ru>...
> Gandu wrote on 20 Ноябрь 2004 17:24:
>
> >
> > foreach $f (@filelist){
> > unless(($f eq ".") || ($f eq "..")){
> > printf("Removing ... $f\n");
> > unlink($f);
> > }
> > }
> >
>
> @filelist contains relative paths. To fix it, prepend $f with
> $directory_name:
>
> foreach $f (map {"$directory_name/$_"} grep {!/^\./} @filelist){
> printf("Removing ... $f\n");
> unlink($f);
> }
------------------------------
Date: 21 Nov 2004 08:44:29 -0800
From: cpptutor2000@yahoo.com (Gandu)
Subject: Re: PLEASE HELP! Perl script does not work!
Message-Id: <3c7c9804.0411210844.2fd6c825@posting.google.com>
Dear Sir,
You are indeed the Perl guru. It has been a pleasure
to hear these words of profound knowledge.
Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrncpv4b0.bor.tadmc@magna.augustmail.com>...
> Gandu <cpptutor2000@yahoo.com> wrote:
>
> > Subject: PLEASE HELP! Perl script does not work!
>
>
> PLEASE HELP! Put the subject of your article in the Subject of your article!
>
> Have you see the Posting Guidelines that are posted here frequently?
>
>
> > Could some Perl guru please help me?
>
>
> You do not need the help of a Perl guru.
>
> You don't even need the help of a Perl programmer of any level.
>
> You only need the help of any programmer, as any of them ought
> to know that
>
> You should read the documentation for the functions that you use.
>
> Are you a programmer?
>
>
> > It runs, but does nothing,
>
>
> If you want to verify that the unlink() unlinked, then you
> should check its return value:
>
> unlink($f) or warn "could not unlink '$f' $!";
>
>
> > Could someone please point what I am doing wrong?
>
>
> You are doing the programming equivalent of signing a contract
> without reading it, namely calling a function without have read
> the documentation for that function.
>
>
> > #!/usr/bin/perl
>
>
> use warnings;
> use strict;
>
> Ask for all the help you can get!
>
>
> > $directory_name = '.mozilla/gandu/uar30qwk.slt/Cache';
>
> > opendir(the_dir, $directory_name) || die("Directory could not be
> > opened");
> >
> > @filelist = readdir(the_dir);
> >
> > foreach $f (@filelist){
> > unless(($f eq ".") || ($f eq "..")){
> > printf("Removing ... $f\n");
> > unlink($f);
>
>
> perldoc -f readdir
>
> If you're planning to filetest the return values out of a
> "readdir", you'd better prepend the directory in question.
> Otherwise, because we didn't "chdir" there, it would have been
> testing the wrong file.
>
>
> You are trying to remove the files from the *current directory*
> rather than the directory where they really are:
>
> unlink( "$directory_name/$f" ) or warn...
------------------------------
Date: Sun, 21 Nov 2004 09:49:11 -0800
From: Arvin Portlock <apollock11@hotmail.com>
Subject: Storing a substitution (similar to qr())
Message-Id: <cnqkeq$2vmo$1@agate.berkeley.edu>
I know how to store a regular expression using qr() but
I can't figure out a way to store the substitution part
of a substitution. For example, this works:
my $example = 'I match this string';
my $match = 'this string';
my $repl = 'that string';
my $regexp = qr($match);
$example =~ s/$regexp/$repl/;
and I get 'I match that string';
But I want to do something like this:
my $example = 'I saw Bob and Alice';
my $match = 'I saw (.*) and (.*)';
my $repl = 'I saw $2 and $1';
my $regexp = qr($match);
$example =~ s/$regexp/$repl/;
print $example;
However this gives me 'I saw $2 and $1' and what I want
is 'I saw Alice and Bob'.
Is there any way to do what I want? I'd like to know the
exact mechanics rather than using some module or another.
Also, is there a way to store the entire substitution, a la
my $subst = qr(s/$regexp/$repl/)?
------------------------------
Date: Sun, 21 Nov 2004 12:30:11 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Storing a substitution (similar to qr())
Message-Id: <slrncq1nlj.pgq.tadmc@magna.augustmail.com>
Arvin Portlock <apollock11@hotmail.com> wrote:
> I know how to store a regular expression using qr() but
> I can't figure out a way to store the substitution part
> of a substitution.
The "substitution part" is also known as "a string". :-)
(but your problem would be solved it you could make it
"some Perl code" instead, see below.
)
> But I want to do something like this:
> my $match = 'I saw (.*) and (.*)';
> my $repl = 'I saw $2 and $1';
> my $regexp = qr($match);
> $example =~ s/$regexp/$repl/;
> Is there any way to do what I want?
perldoc -q string
How can I expand variables in text strings?
Then:
my $repl = '"I saw $2 and $1"';
^ ^ note the quotes
...
$example =~ s/$regexp/$repl/ee;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7434
***************************************