[17085] in Perl-Users-Digest
Perl-Users Digest, Issue: 4497 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 2 18:22:02 2000
Date: Mon, 2 Oct 2000 15:21:39 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <970525298-v9-i4497@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 2 Oct 2000 Volume: 9 Number: 4497
Today's topics:
Re: Regex comparing street addresses <peter.sundstrom@eds.com>
Re: Regex comparing street addresses <peter.sundstrom@eds.com>
Re: regexp unexp. returns status instead of pattern michaeljgardner@my-deja.com
Re: Result of functions in child processes <Torsten.Schindler@ccc.uni-erlangen.de>
Re: Reverse by paragraphs - NOT! <jeffp@crusoe.net>
Re: Reverse by paragraphs - NOT! <bart.lateur@skynet.be>
Re: Reverse by paragraphs - NOT! <bmb@ginger.libs.uga.edu>
Re: Search and Destroy rathmore@tierceron.com
Re: Search and Destroy <lr@hpl.hp.com>
Re: Search and Destroy rathmore@tierceron.com
Sendmail/Perl question glwillia@my-deja.com
Re: Sendmail/Perl question <aslay@ucsd.edu>
Re: Sendmail/Perl question <bmb@ginger.libs.uga.edu>
Should Work? malatov@my-deja.com
Re: sort files (Randal L. Schwartz)
Re: sort files <lr@hpl.hp.com>
Re: Sorting of Form-Fields ??? (Steve A.)
Re: starting with perl. (Steve A.)
Re: starting with perl. <lr@hpl.hp.com>
Re: starting with perl. <uri@sysarch.com>
Re: starting with perl. <uri@sysarch.com>
Re: Strange behaviour with @{...} <bart.lateur@skynet.be>
Re: Time Zone conversion <jhaworth@solution-soft.com>
upload script <tille@post11.tele.dk>
Re: What's wrong with this regex? <peter.sundstrom@eds.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 3 Oct 2000 10:05:00 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Regex comparing street addresses
Message-Id: <8rathc$fc1$1@hermes.nz.eds.com>
Jim Mauldin wrote in message <39D81F62.DE33E3A8@netstorm.net>...
>Peter Sundstrom wrote:
>>
>> The comparison involves:
>>
>> Reversing the order of any two adjacent address identifiers (where
>> identifier is a group of alphanumeric characters preceded and followed by
a
>> space and containing at least one numeric character) in the first address
>> and then comparing it against the second to see if they match.
>
>I'm sure you meant "identifier ... separated by a space" rather than
>"preceded and followed by a space". You also contradict yourself by
>saying that the identifiers you're interested in must have at least one
>digit, in which case:
>
>> APARTMENT 4 123A SMITH ST,FLAT 123A 4 SMITH ST
>> DIFFERENT
>
>should be SAME because FLAT and APARTMENT are irrelevant (don't have a
>digit), and the relevant portions 4 and 123A are in fact adjacent and in
>reverse order.
Perhaps I didn't spell it out as precisely as I should have. The
identifiers *must* have a space before and after them (therefore wouldn't
match at the beginning or end of line). When the identifiers are reversed
in the first address, the *whole* address line is then compared with the
second address.
------------------------------
Date: Tue, 3 Oct 2000 10:06:06 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Regex comparing street addresses
Message-Id: <8ratjf$fej$1@hermes.nz.eds.com>
Andrew N. McGuire wrote in message ...
>On Mon, 2 Oct 2000, Peter Sundstrom quoth:
>
>PS> I'm having problems trying to get the correct regex to perform an
address
>PS> comparison.
>PS>
>PS> The comparison involves:
>PS>
>PS> Reversing the order of any two adjacent address identifiers (where
>PS> identifier is a group of alphanumeric characters preceded and followed
by a
>PS> space and containing at least one numeric character) in the first
address
>PS> and then comparing it against the second to see if they match.
>
>[ snip code ]
>
>I would consider doing it a different way, you don't necessarily need
>a regex for this, and I think that the below is a lot easier to read.
>Of course there is a problem with the below, and that is:
>
>'TOP APARTMENT 4 123A SMITH ST'
>
>will match
>
>'ST 4 TOP APARTMENT 123A SMITH'
>
>which probably is not desired, but then again, you may not care.
It has to be an exact match. I was thinking along the lines of using sort
until I found out the order had to be exact.
------------------------------
Date: Mon, 02 Oct 2000 21:22:48 GMT
From: michaeljgardner@my-deja.com
Subject: Re: regexp unexp. returns status instead of pattern
Message-Id: <8raub0$aqc$1@nnrp1.deja.com>
In article <8ra19k$h2j$1@nnrp1.deja.com>,
crb <chris_beaudette@my-deja.com> wrote:
> greetings.
>
> i'm writing a perl script and have a regular expression that is
> occasionally matching. but when it matches, it returns a status of
"1"
> instead of the pattern matched. what am i doing wrong?
>
> here's the expression and supporting script:
> -----------------------------------------------
> foreach $logfile ( @logfiles ) {
> $_ = $logfile;
> print "default param = ", $_, "\n";
> local ($namebase) = s/(.+)\..+/$1/; ### <<<<---- regexp
> print "namebase = '", $namebase, "'\n";
> local( $tempfile ) = $namebase . ".tmp\n";
> print "tempfile = ", $tempfile, "\n";
> ...
> }
I think it would look nicer, and work if you did this instead;
foreach $logfile (@logfiles){
print "defualt param = $logfile\n";
local($namebase)=$logfile;
$namebase=~s/(.+)\..+/$1/;
print "namebase = $namebase\n";
local($tempfile)=$namebase.'.tmp\n';
print "tempfile = $tempfile, \n"
}
Also, is there a reason you're using the local() for the variables
inside the loop. Is there additional code in the loop that creates a
reference to these variables?
You might even want to change your regex to simply replace the file's
extension with nothing.
$namebase=~s/\..+//
HTH,
Michael
for(split//,'K=KKO0=<0O0=K0O@=-0OHKK0OOK=KK=KKO=E=0=<=OKA=0KKKO=?=0=<'.
'>O==K0=K=OOK,,<O=HB<OK@E<O<D<<O<J<DOO=KK=KKO==<><=OKK<HKKO==<><>O==K'.
'=K='){if(/O/){$r.=$/;next}vec($d,0,8)=(ord)-44;$r.=unpack('B8',$d)}$r
=~y/10/_ /;print$r
> -----------------------------------------------
>
> the output is as follows:
> -----------------------------------------------
> default param = update_compile.bak
> namebase = '1'
> tempfile = 1.tmp
> -----------------------------------------------
>
> note that i've also tried:
> local ($namebase) = s/(\w)\.\w/$1/;
>
> to the same result.
>
> any ideas???
>
> thanks!
>
> ~~crb
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 02 Oct 2000 20:19:42 +0200
From: Torsten Schindler <Torsten.Schindler@ccc.uni-erlangen.de>
Subject: Re: Result of functions in child processes
Message-Id: <39D8D1BE.6F550ECC@ccc.uni-erlangen.de>
Martien Verbruggen wrote:
> >
> > How can I get the result of my function afunc back from the child
> > process?
>
> # perldoc perlipc
>
I have read it, but it wasn't very useful.
Or can I pipe variables form a child to a parent process?
Torsten
------------------------------
Date: Mon, 2 Oct 2000 16:43:27 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <Pine.GSO.4.21.0010021635300.14163-100000@crusoe.crusoe.net>
On Oct 2, Godzilla! said:
>There are two undocumented functions in Perl
[bzzt] What functions are you talking about? 'while' is a loop
constructor, not a function. And 'slurping' is a name for reading all of
input at once. Check the definition of 'function' -- you're not quite
right here.
>local ($/) =3D "=A9";
>
>open (TEST, "test.txt");
>$data =3D <TEST>;
>close (TEST);
Breaks if test.txt has any =A9 characters in it. There's a time for
specificity, and a time for generality. Be general here. And there's no
reason for local() here at all.
{
local $/;
$data =3D <TEST>;
}
That's slurping. It's not a function. It's a nickname for the process of
reading all of a filehandle at once.
>@Array =3D split (/\n\n/, $data);
Why not do:
{
local $/ =3D "";
while (<TEST>) {
# ...
}
}
$/ being "" makes Perl read in "paragraph" mode, like the original poster
was trying to get. You should be doing /\n\n+/ if you want to get the
proper behavior.
Geez. I sure hope Mothra shows up and shoos you away.
--=20
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Mon, 02 Oct 2000 21:10:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <t8uhtskf5on8r3vfr7ple6e5msf5q7qd8r@4ax.com>
>I am trying to process a file that has the following description:
>It has a report header on each page. The data that follows the header
>consists of paragraphs of data entered sequentially from a
>manufacturing process(processing sector, when entered, data acquired,
>etc.). There's no blank lines in a paragraph, but each paragraph is
>terminated by a blank line. It's complicated by the fact that the file
>is "upside-down", with the most recent paragraph at the top, the first
>paragraph at the bottom.
>
>I successfully read-in the file, trash the header(after extracting some
>data), then discard certain irrelevant paragraphs, saving the keepers
>in array @OF. For convenience, I would then like to reverse the file so
>the initial paragraph is at the top, the most recent at the bottom. I
>seem unable to get the reversing procedure (from the Perl Cookbook) to
>work - the whole file is reversed line by line, not paragraph by
>paragraph. I include the code below. Where am I going wrong?
>{
>local $/ = '';
>@ROF=reverse @OF;
>}
It's a bit late for that, isn't it? You should have set paragraph mode
($/ = empty string) while reading in the file. Each array item should
have been a paragraph, not a line.
Now, whether or not your headers are paragrapsh too, isn't clear to me.
If not, you may have to switch between line mode an paragraph mode all
the time.
Since you don't provide sample data, I can't go into any more detail
than this. Sorry.
--
Bart.
------------------------------
Date: Mon, 2 Oct 2000 17:25:32 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <Pine.A41.4.21.0010021720540.14510-100000@ginger.libs.uga.edu>
On Mon, 2 Oct 2000 ollie_spencer@my-deja.com wrote:
> Hi- Another tale of woe.
>
> I am trying to process a file that has the following description:
> It has a report header on each page. The data that follows the header
> consists of paragraphs of data entered sequentially from a
> manufacturing process(processing sector, when entered, data acquired,
> etc.). There's no blank lines in a paragraph, but each paragraph is
> terminated by a blank line. It's complicated by the fact that the file
> is "upside-down", with the most recent paragraph at the top, the first
> paragraph at the bottom.
>
> I successfully read-in the file, trash the header(after extracting some
> data), then discard certain irrelevant paragraphs, saving the keepers
> in array @OF. For convenience, I would then like to reverse the file so
> the initial paragraph is at the top, the most recent at the bottom. I
> seem unable to get the reversing procedure (from the Perl Cookbook) to
> work - the whole file is reversed line by line, not paragraph by
> paragraph. I include the code below. Where am I going wrong?
You say that the paragraphs are stored in @OF, but it looks to me like
you're storing lines there. Take a look at the $/ variable (perldoc
perlvar). Setting it to "" will let you read your file paragraph by
paragraph.
Brad
------------------------------
Date: Mon, 02 Oct 2000 18:42:40 GMT
From: rathmore@tierceron.com
Subject: Re: Search and Destroy
Message-Id: <8rakuv$1ut$1@nnrp1.deja.com>
> @sourcefile = $ftp->ls('/some_directory/');
> # Need some code here between these two lines!
> $numOrderFiles = @sourcefile; # Holds the number of files found in
> previous line
Here is the solution that I came up with after much trial and error.
(Did I mention that I'm new to Perl?) I'm posting it here in the off
chance that someone else has a similar question, and also to see if any
of the more experienced folks have a more optimal solution.
@filelist = $ftp->ls('/some_directory/');
foreach $filelist (@filelist) {
if ($filelist =~ /(.txt|.TXT)/) {
@sourcefile = (@sourcefile, $filelist);
}
}
$numOrderFiles = @sourcefile;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 2 Oct 2000 13:19:04 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Search and Destroy
Message-Id: <MPG.14428d90738dcb1f98adf0@nntp.hpl.hp.com>
In article <8rakuv$1ut$1@nnrp1.deja.com> on Mon, 02 Oct 2000 18:42:40
GMT, rathmore@tierceron.com <rathmore@tierceron.com> says...
>
> > @sourcefile = $ftp->ls('/some_directory/');
> > # Need some code here between these two lines!
> > $numOrderFiles = @sourcefile; # Holds the number of files found in
> > previous line
>
> Here is the solution that I came up with after much trial and error.
> (Did I mention that I'm new to Perl?) I'm posting it here in the off
> chance that someone else has a similar question, and also to see if any
> of the more experienced folks have a more optimal solution.
>
> @filelist = $ftp->ls('/some_directory/');
> foreach $filelist (@filelist) {
> if ($filelist =~ /(.txt|.TXT)/) {
The '.' is a metacharacter, and you want a break at the end.
> @sourcefile = (@sourcefile, $filelist);
perldoc -f push
But 'grep' is better; see below.
> }
> }
> $numOrderFiles = @sourcefile;
my $numOrderFiles = my @sourceFile =
grep /\.txt\b/i => $ftp->ls('/some_directory/');
But I hate studlyCaps, which belong in Java, not in Perl.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 02 Oct 2000 21:27:12 GMT
From: rathmore@tierceron.com
Subject: Re: Search and Destroy
Message-Id: <8rauj6$auv$1@nnrp1.deja.com>
> my $numOrderFiles = my @sourceFile =
> grep /\.txt\b/i => $ftp->ls('/some_directory/');
Larry, that is beautiful. You can't see because this is a digital
medium, but I'm grinning from ear to ear because I love this language,
and you're the coolest!
> But I hate studlyCaps, which belong in Java, not in Perl.
Aye, but it was mandated upon me as my co. is predominately Java
developers.
Rathmore
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 02 Oct 2000 20:09:19 GMT
From: glwillia@my-deja.com
Subject: Sendmail/Perl question
Message-Id: <8raq17$6mr$1@nnrp1.deja.com>
I have a script whose purpose is to invoke sendmail to send an email to
some specified email addresses. The problem is, sometimes the script
sends the email from the correct email address, and other times the
email appears to come from "localhost.localdomain" Here is the relevant
section of the perl script:
# $mailprog eq 'sendmail';
open(MAIL,"|$mailprog -t");
# $email_addrs is the email field in a database
print MAIL "To: $email_addrs\n";
print MAIL "From: address\@domain.com\n";
print MAIL "Subject: Your xxxxxxx Channel\n\n";
print MAIL <<"EOT";
Mail message goes here...
EOT
close (MAIL);
Anyone have any ideas?
Thanks,
Grayson
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 02 Oct 2000 14:33:23 -0700
From: Rip Curl <aslay@ucsd.edu>
Subject: Re: Sendmail/Perl question
Message-Id: <39D8FF23.452B0769@ucsd.edu>
Why don't you just do it like this
open(MAIL,"|sendmail -t $email_addrs");
and forget about the "To:" line. This might solve your problem. You might
have to ditch the -t too.
glwillia@my-deja.com wrote:
> I have a script whose purpose is to invoke sendmail to send an email to
> some specified email addresses. The problem is, sometimes the script
> sends the email from the correct email address, and other times the
> email appears to come from "localhost.localdomain" Here is the relevant
> section of the perl script:
>
> # $mailprog eq 'sendmail';
> open(MAIL,"|$mailprog -t");
> # $email_addrs is the email field in a database
> print MAIL "To: $email_addrs\n";
> print MAIL "From: address\@domain.com\n";
> print MAIL "Subject: Your xxxxxxx Channel\n\n";
> print MAIL <<"EOT";
>
> Mail message goes here...
>
> EOT
> close (MAIL);
>
> Anyone have any ideas?
>
> Thanks,
>
> Grayson
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Mon, 2 Oct 2000 17:54:11 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Sendmail/Perl question
Message-Id: <Pine.A41.4.21.0010021750050.14510-100000@ginger.libs.uga.edu>
On Mon, 2 Oct 2000, Rip Curl wrote:
> Why don't you just do it like this
>
> open(MAIL,"|sendmail -t $email_addrs");
>
> and forget about the "To:" line. This might solve your problem. You might
> have to ditch the -t too.
>
Uh, no. -t tells sendmail to look for "To:"
This is in general more secure.
perldoc -q "how do i send mail"
Please note, I'm not attempting to answer the OP, but it might help
anyway.
Brad
------------------------------
Date: Mon, 02 Oct 2000 18:57:11 GMT
From: malatov@my-deja.com
Subject: Should Work?
Message-Id: <8ralq2$2l1$1@nnrp1.deja.com>
Can someone please try this script and see if they can get it to work?
use LWP::UserAgent;
use HTTP::Cookies;
$ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave
=> 1));
$url = "http://www.museumcompany.com/misc/paris/signup.asp";
my $req = HTTP::Request->new(post => $url);
$req->content_type('application/x-www-form-urlencoded');
$req->content('fist_name=bob');
my $res = $ua->request($req);
print $res->as_string;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 02 Oct 2000 06:35:37 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: sort files
Message-Id: <m1lmw7mkly.fsf@halfdome.holdit.com>
>>>>> "Rafael" == Rafael Garcia-Suarez <rgarciasuarez@free.fr> writes:
Rafael> So you can get the sorted list by:
Rafael> my @sorted = sort { (stat($a))[9] <=> (stat($b))[9] } @files;
As long as it's a very short list, or you don't mind waiting a bit.
If it's long, you'll want an ST or a GRT or memoized or orc-ish sort
in here. Various other postings in the last three weeks should
answer that. :)
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 2 Oct 2000 12:33:42 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: sort files
Message-Id: <MPG.144282f254343aee98aded@nntp.hpl.hp.com>
In article <slrn8tglg7.pbs.rgarciasuarez@rafael.kazibao.net> on Mon, 02
Oct 2000 09:25:05 GMT, Rafael Garcia-Suarez <rgarciasuarez@free.fr>
says...
> Calvin wrote in comp.lang.perl.misc:
> >I want to sort the files and directories by last modified. What should I
> >add/change ? Thank you very much!
>
> Get the last modification time with:
> my $mtime = (stat($filename))[9];
> (make sure that $filename is not only the filename, but the full path
> to it, i.e. with the directory name prepended.)
> So you can get the sorted list by:
> my @sorted = sort { (stat($a))[9] <=> (stat($b))[9] } @files;
Note, though, that the above wastes a lot of cycles doing repeated
stats, which matters if the directory has many files. See the
documentation for more efficient ways of doing this. Here is one
source:
http://www.hpl.hp.com/personal/Larry_Rosler/sort/
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 02 Oct 2000 17:53:47 GMT
From: sarbayo@telis.org (Steve A.)
Subject: Re: Sorting of Form-Fields ???
Message-Id: <39d8c97d.194818@news.inreach.com>
>in my Form there are ca. 25 Fields. I want to output this fields
>automatic in the same sorting-order as they are in the Form,
>but the perl-script recieves them not sorted...
>
>Is there a way to fix this??? Without outputting manually???
Yes,
it requires two moifications:
1) add " use CGI.pm; " to (near) the top of your script,
2) add numbers to each of your HTML 25 fields
ie:
" 01_field, 02_field, ......25_field
------------------------------
Date: Mon, 02 Oct 2000 17:40:25 GMT
From: sarbayo@telis.org (Steve A.)
Subject: Re: starting with perl.
Message-Id: <39d8c211.2527318@news.inreach.com>
>> The correct name of the language is Perl.
Joe, ignore this Elite-ist Bullshit !
It doesn't matter !
You can call it Perl, PERL, perl, purr'l, what ever you want !!!
It's only the Elite-ists who care.
>> > trying to get my scrips to save a data file. Are there any perl
when you open a file, you have to tell it in what mode you want to use
the file.
IE: Read, Write, or Read/Write, etc.
You do this with these symbols :
the " < " symbol means Read
the " > " symbol means Write, ( Create or OverWrite )
the " >> " symbols means Append (add to a file)
the " +< " symbols mean Read and Write
This must be added to the open command:
"
open (Handle, ">>guest_book.txt";
print Handle $Data;
close(Handle);
"
This code will append whatever information is in $Data to the
"guest_book.txt" file.
>> If you want help here, you will have to be much much more specific.
>> Exactly what problem? Did you get an error message? If so, what did it
>> say?
Very true !!!
>> > Also I am trying to print out my guest book.
Also very simple:
"
open (Handle, "<guest_book.txt";
while(<Handle>) {
print;
$Data .= $_;
}
close(Handle);
"
these lines of code will read in the entire "guest_book.txt" file,
print it to screen/browser and put it in the string "$Data ", so that
you can do whatever you want with it.
> I tried to use www.annuna.com/cgi-bin/logs/logfile.txt.
Ordinarily, if your perl.pl script is in /cgi-bin/ you dont need to
use the entire URL.
Only the " /logs/logfile.txt " should be required.
So the above examples would read:
">/logs/logfile.txt" and "</logs/logfile.txt"
Try these, they should work.
------------------------------
Date: Mon, 2 Oct 2000 12:17:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: starting with perl.
Message-Id: <MPG.14427f0bea2b9ffe98adeb@nntp.hpl.hp.com>
In article <39d8c211.2527318@news.inreach.com> on Mon, 02 Oct 2000
17:40:25 GMT, Steve A. <sarbayo@telis.org> says...
> >> The correct name of the language is Perl.
>
> Joe, ignore this Elite-ist Bullshit !
> It doesn't matter !
> You can call it Perl, PERL, perl, purr'l, what ever you want !!!
> It's only the Elite-ists who care.
It is a matter of simple courtesy to call a child by the name its
parents gave it, instead of whatever pleases you the most. In this
case, the parent is Larry Wall, who has made his choice clear. See
perlfaq1.
> >> > trying to get my scrips to save a data file. Are there any perl
>
> when you open a file, you have to tell it in what mode you want to use
> the file.
> IE: Read, Write, or Read/Write, etc.
>
> You do this with these symbols :
> the " < " symbol means Read
... and is the default if no 'symbol' is specified.
> the " > " symbol means Write, ( Create or OverWrite )
> the " >> " symbols means Append (add to a file)
> the " +< " symbols mean Read and Write
>
> This must be added to the open command:
> "
> open (Handle, ">>guest_book.txt";
That doesn't compile, and doesn't have the failure diagnostic that the
'Elite-ists' here insist on.
...
> > I tried to use www.annuna.com/cgi-bin/logs/logfile.txt.
>
> Ordinarily, if your perl.pl script is in /cgi-bin/ you dont need to
> use the entire URL.
> Only the " /logs/logfile.txt " should be required.
> So the above examples would read:
>
> ">/logs/logfile.txt" and "</logs/logfile.txt"
That is extraordinarily bad advice, which must be corrected.
First, you have specified an absolute path. I doubt very much that the
directory 'logs' resides in the root directory.
Secondly, after you remove the incorrect leading slash, you are left
with a path relative to the current directory. You blithely assume that
that is the directory of the program itself, but that is not guaranteed.
Somehere there is a quote (from Tom Phoenix, IIRC) that anyone using a
relative filepath in a CGI program without explicitly setting the
current directory is living in a state of sin.
> Try these, they should work.
If corrected.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 02 Oct 2000 19:27:21 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: starting with perl.
Message-Id: <x7r95z59ie.fsf@home.sysarch.com>
>>>>> "SA" == Steve A <sarbayo@telis.org> writes:
SA> Joe, ignore this Elite-ist Bullshit !
SA> This must be added to the open command:
SA> "
is that quote part of the syntax?
SA> open (Handle, ">>guest_book.txt";
is it elitist to get the syntac correct? how about closing the parens
there? and file handles are usually all upper case.
SA> print Handle $Data;
and variable names are usually all lower case.
how elitist we must seem to encourage standardizations like this and
calling the language by its proper name.
SA> open (Handle, "<guest_book.txt";
same bug as before.
SA> Try these, they should work.
only if they are fixed first.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 02 Oct 2000 19:30:56 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: starting with perl.
Message-Id: <x7n1gn59ce.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> That doesn't compile, and doesn't have the failure diagnostic that the
LR> 'Elite-ists' here insist on.
i am just waiting for his obligatory flame that correcting his code is
elitist.
counting 1 2 3 ....
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 02 Oct 2000 18:49:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Strange behaviour with @{...}
Message-Id: <pslhtsgk1hmsd6rg8ksl16fdtm307eg5si@4ax.com>
Volker Moell wrote:
> my $a = undef;
> print $a;
> foreach (@{$a}) { }
> print $a;
> -------------------------(snapp)------------------------
>
>The output (both 5.6.x and 5.0.x) will be:
>
> -------------------------(snipp)------------------------
> Use of uninitialized value in print at ./test.pl line 5.
> ARRAY(0x80eedb0)
> -------------------------(snapp)------------------------
>
>My question is: Why does @{...} changes the value of the variable $a?
Autovivification, I guess. Perl tries to be helpful, which it is, in
some similar but different cases:
my %hash;
push @{$hash{abc}}, 123;
push @{$hash{abc}}, 456;
use Data::Dumper;
print Dumper \%hash;
-->
$VAR1 = {
'abc' => [
123,
456
]
};
Note that the first time you access $hash{abc}, it doesn't exist yet.
After the first push statement, it does, and it contains the data you
just pushed onto it. It's handy, you don't have to pre-initialize the
hash for every possible hash key.
my $a;
push @{$a}, 123;
push @{$a}, 456;
use Data::Dumper;
print Dumper $a;
-->
$VAR1 = [
123,
456
];
Ah, yes. Same effect.
--
Bart.
------------------------------
Date: Mon, 02 Oct 2000 19:30:08 -0000
From: TimeMachine <jhaworth@solution-soft.com>
Subject: Re: Time Zone conversion
Message-Id: <sthoi0c61h8863@corp.supernews.com>
Michael-
You may benefit from our software called Time Machine. This allows you to
provide a virtual clock for your users logged into the network. It already
takes into account all the time zones and Daylight Savings Times in the
world.
You can check out some more information at http://www.solution-soft.com or
give me a call.
thanks,
Jeff Haworth
Solution-Soft
408-346-1430
jhaworth@solution-soft.com
Michael Love wrote:
>
>
> Thanks, but it's not the idea of timezone conversion I'm having problems
> with. I was hoping that someone already had a piece of code out there
that
> would check for DST in another timezone without having to write it myself
> and duplicate the effort.
>
> I found this webpage: http://www.webexhibits.org/daylightsaving/g.html
that
> gives me a chart of countries and when their DST starts and ends. As you
can
> see from these... such as calculating the "First Sunday in April" and the
> "Last Sunday in October", or even "First Sunday on or after the 9th of
> October"... this can be rather involved.
>
> This is meant to be a modification to a program, not as a programming
> project on its own. If I have to write up a module to do this from
scratch,
> I'll do it, but I want to make sure that there sin't something out there
> already.
>
>
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Mon, 2 Oct 2000 21:16:54 +0100
From: "Peter Tilsted" <tille@post11.tele.dk>
Subject: upload script
Message-Id: <8ran0j$hj8$1@news.inet.tele.dk>
hello there
I am looking for an perl file upload script that works with a NT server.
it should work with all kind of filetypes.
I have been searching various code collections but all samples i have found
is for Unix, i was hoping somebody had a script they where willing to share.
TIA
Peter
------------------------------
Date: Tue, 3 Oct 2000 09:57:02 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: What's wrong with this regex?
Message-Id: <8rat2g$edm$1@hermes.nz.eds.com>
Ivo Swartjes wrote in message <8ra65h$m19$1@dinkel.civ.utwente.nl>...
>Hi guys,
>
>I'm trying to strip a filename from a path+filename, and am trying to do it
>like this ($filename is the path+filename):
>
>$filename =~ /\\(.+?)$/;
>
>I then try to put the part between ( ) in a new variable:
>
>$lastpart = $1;
>
>But it won't work, it matches the whole $filename, or so it seems.
Have you seen
perldoc Basename
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4497
**************************************