[22288] in Perl-Users-Digest
Perl-Users Digest, Issue: 4509 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 4 06:08:35 2003
Date: Tue, 4 Feb 2003 03:06:41 -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 Tue, 4 Feb 2003 Volume: 10 Number: 4509
Today's topics:
Re: 100 levels deep redux. <goldbb2@earthlink.net>
Re: APL's relation to perl <bik.mido@tiscalinet.it>
Re: APL's relation to perl <tassilo.parseval@post.rwth-aachen.de>
Re: Attachments show in body, but only with Kmail <abigail@abigail.nl>
Re: Attachments show in body, but only with Kmail <spamfilter@cheiron-it.nl>
Re: Attitude to Perl in academia (aka ? the Platypus)
Re: Attitude to Perl in academia <ubl@schaffhausen.de>
Re: Build my own perl html help docs (Helgi Briem)
Re: Converting C code to perl but the results are not t <bigj@kamelfreund.de>
Re: How to close all ports ??? news@roaima.freeserve.co.uk
Re: Need OS-independent module for starting "fire-and-f (John Ramsden)
Re: Parse a logfile - 1st column DateStamp; extract lat (Tim Cargile)
Re: perl simple script <bigj@kamelfreund.de>
Re: read web content (R Solberg)
Re: sort, my concoction of <tassilo.parseval@post.rwth-aachen.de>
Re: strange localtime return (Anno Siegel)
Re: Tainting individual variables (John Ramsden)
Until loop not working with multiple conditions (Paul)
Re: Until loop not working with multiple conditions <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Until loop not working with multiple conditions <mbudash@sonic.net>
Re: Until loop not working with multiple conditions <bigj@kamelfreund.de>
Re: Until loop not working with multiple conditions <jurgenex@hotmail.com>
Re: why does not this work thumb_42@yahoo.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 04 Feb 2003 01:19:15 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: 100 levels deep redux.
Message-Id: <3E3F5B63.9A97FAA6@earthlink.net>
Ron Smith wrote:
>
> I'm still having the classic 100 levels deep issue when using the
> debugger.
Type perldoc -l DB, open that file in your editor, and change $deep from
100 to something larger. [untested]
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: Tue, 04 Feb 2003 09:49:42 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: APL's relation to perl
Message-Id: <g1vu3v85443q5ha4hh3bkt53cbquug6if4@4ax.com>
On Mon, 03 Feb 2003 17:53:19 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:
>You get an aliasing effect regardless of whether you use $_ or some
>other variable name.
>
> my @foo = (1, 2, 3);
> foreach my $x (@foo) { $x *= 2 }
> print @foo; # prints 246
Sorry, I do know in general what 'aliasing' is in programming
languages context. For some reason yesterday I was unable to connect
this plain piece of information with the subject matter we're
discussing!
>If @foo was an array of pairs, and iterated over those pairs, as in:
> foreach my $pair (@foo) { my ($x, $y) = @$pair; ...stuff... }
>, then altering $x and $y won't alter the @foo array.
Of course: this is with the current syntax/semantic; but this might
possibly change in the future...
>Read these:
[list of apocalypses & exegeses mostly snipped]
OK, I won't bother you any more in this thread now gone completely OT.
> http://dev.perl.org/perl6/apocalypse/6
BTW: I don't think this exists (just checked quickly), does it?
>The only way, in perl5, to make something like
> my @crossprod = @a (x) @b;
> work would be to create a source filter, which finds stuff like that
^^^^^^^^^^^^^
>and changes the @a (x) @b into some_function(\@a, \@b).
Where is this kind of things documented? Do you consider it to be too
far above the top of a relative newbie's head, anyway?
Michele
--
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth. See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"
------------------------------
Date: 4 Feb 2003 09:06:54 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: APL's relation to perl
Message-Id: <b1nvre$ar$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Michele Dondi:
> On Mon, 03 Feb 2003 17:53:19 -0500, Benjamin Goldberg
><goldbb2@earthlink.net> wrote:
>
>>You get an aliasing effect regardless of whether you use $_ or some
>>other variable name.
>>
>> my @foo = (1, 2, 3);
>> foreach my $x (@foo) { $x *= 2 }
>> print @foo; # prints 246
>
> Sorry, I do know in general what 'aliasing' is in programming
> languages context. For some reason yesterday I was unable to connect
> this plain piece of information with the subject matter we're
> discussing!
I don't know whether 'aliasing' is a general concept in programming
languages context. But it is certainly a concept to know about in Perl.
It really means what it sounds like: You have two names for the same
thing. There are a couple of spots where aliasing comes into the game in
Perl. For instance:
1) subroutine arguments:
sub double { $_[0] *= 2 }
my $var = 2;
double($var);
print $var; # prints: 4
That means that all the arguments that end up in @_ are actually
aliased. Changing $_[0], $_[1],... will change the respective values
that were passed. Note that it does not work with literals:
sub double { $_[0] *= 2 }
double(2);
__END__
Modification of a read-only value attempted at - line 1.
That's what you would expect since you can't assign to a literal value.
You always need a variable to assign to.
2) for-loops:
my @list = (1, 2, 3);
for my $var (@list) {
$var *= 2;
}
print "@list";
__END__
2 4 6
Again, you need variables that are aliased. You can't do it with a bare
list of literals:
for my $var (1, 2, 3) {
$var *= 2;
}
__END__
Modification of a read-only value attempted at - line 2.
[...]
>>The only way, in perl5, to make something like
>> my @crossprod = @a (x) @b;
>> work would be to create a source filter, which finds stuff like that
> ^^^^^^^^^^^^^
>>and changes the @a (x) @b into some_function(\@a, \@b).
>
> Where is this kind of things documented? Do you consider it to be too
> far above the top of a relative newbie's head, anyway?
It is hidden in modules. Filter::Util::Call is the most powerful
implementation of it. Damian Conway has written a more usable front-end
for it (see Filter::Simple on the CPAN).
I don't think it is 'far above the top of a relative newbie's head'.
Perl does not impose an order in which you are supposed to learn the
language. If you call yourself a newbie but think that source-filters
are cool, then please use them. Everyone is allowed to indulge with
whatever feature/subset he/she likes best about Perl. That's part of
Perl's success.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 04 Feb 2003 08:17:10 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Attachments show in body, but only with Kmail
Message-Id: <slrnb3uto6.8fm.abigail@alexandra.abigail.nl>
Robert (robert@nrc.net) wrote on MMMCDXLIV September MCMXCIII in
<URL:news:22d0e990.0302031650.66f5bc18@posting.google.com>:
** I have a PERL script that mails an attachment of a .csv file. It works
** fine with Outlook, Outlook Express, Incredimail, Netscape, and The
** Bat. However Kmail with Linux shows the attachment in the mail body,
** NOT attaching it at all. Can someone tell me why that may be
** happening? Any help is greatly appreciated.
What makes you think this is a Perl (That's capital P, lowercase e,
lowercase r, lowercase l - it's a name, not an acronym) issue?
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Tue, 4 Feb 2003 09:57:16 +0100
From: "Frank Maas" <spamfilter@cheiron-it.nl>
Subject: Re: Attachments show in body, but only with Kmail
Message-Id: <3e3f806c$0$147$e4fe514c@dreader5.news.xs4all.nl>
"Robert" <robert@nrc.net> schreef in bericht
news:22d0e990.0302031650.66f5bc18@posting.google.com...
> I have a PERL script that mails an attachment of a .csv file. It works
> fine with Outlook, Outlook Express, Incredimail, Netscape, and The
> Bat. However Kmail with Linux shows the attachment in the mail body,
> NOT attaching it at all. Can someone tell me why that may be
> happening? Any help is greatly appreciated.
This has probably nothing to do with Perl, but with KMail that recognizes
the attachment as a mere text-file and immediately shows it. Consider it
a feature.
--Frank
------------------------------
Date: Tue, 04 Feb 2003 05:11:43 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@dformosa.zeta.org.au>
Subject: Re: Attitude to Perl in academia
Message-Id: <slrnb3uj4o.pv3.dformosa@dformosa.zeta.org.au>
On Sun, 02 Feb 2003 18:05:55 +0100, Malte Ubl <ubl@schaffhausen.de> wrote:
[...]
> Actually, I think that some Smalltalk Implementation even have a method
> in Object called:
> changeClassToThatOf: aSymbol
> which is, as far as I know, not possible in Perl (One could hack around
> it doing tricks with ISA, I guess).
You can rebless objects into diffrent classes. Of cause it will most
likely cause a big mess but it is possable.
--
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.
------------------------------
Date: Tue, 04 Feb 2003 10:07:17 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Attitude to Perl in academia
Message-Id: <b1o33o$bpn$1@news.dtag.de>
David Formosa (aka ? the Platypus) wrote:
> You can rebless objects into diffrent classes. Of cause it will most
> likely cause a big mess but it is possable.
I thought I tried this before and it didn't work, but obviously it does.
Tell Erich Gamma that we don't need the Decorator Pattern anymore :)
->malte
------------------------------
Date: Tue, 04 Feb 2003 10:29:22 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Build my own perl html help docs
Message-Id: <3e3f9509.497653928@news.cis.dfn.de>
On 4 Feb 2003 03:34:52 GMT, Shing-Fat Fred Ma
<fma@doe.carleton.ca> wrote:
>> One easy solution: On a Windoze machine somewhere, install the latest
>> version of ActiveState Perl. Use ppm to install the extra modules you
>> want docs of. Then copy the c:\perl\html file hierarchy to the machine
>> where you want the HTML docs.
A good idea, but not as good as just installing Activeperl
on the target machine.
>I'm a bit paranoid about installing something
>other than generic Perl on my machine right
>now. At this time, I want to stick with something
>totally no-name. I may consider otherwise once
>I have a solid grounding. My concern about
>installing any software on my machine is that
>I may not be aware of all the side effects, such
>as search paths on *nix, or registry on the PC
>(and I admit, I am very unfamiliar with PC, which
>again is why I'm cautious).
Activestate Perl is just as generic and ubiquitous
as any other Perl distribution. It includes a very good
range of standard modules. Don't worry about
any registry effects, AS Perl only adds the C:/Perl/bin
directory to your path and associates C:/Perl/bin/perl.exe
with the .pl file extension.
> In your opinion, how self contained is an Active State
>Perl?
I don't know what that means. It requires no other
programs beyond the base OS, if that's what you mean.
>Is it free?
Yes.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Tue, 04 Feb 2003 09:02:18 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Converting C code to perl but the results are not the same
Message-Id: <pan.2003.02.04.08.01.28.601703@kamelfreund.de>
On Mon, 03 Feb 2003 12:51:29 -0800, Mothra wrote:
> **************c code******************
>
> #define days_since_2000_Jan_0(y,m,d) \
> (367L*(y)-((7*((y)+(((m)+9)/12)))/4)+((275*(m))/9)+(d)-730530L)
> main()
> {
> ...
> ...
> sub days_since_2000_Jan_0 {
>
> my ($y,$m,$d) = @_;
>
> my $dl =
> (367*($y)-((7*(($y)+((($m)+9)/12)))/4)+((275*($m))/9)+($d)-730530);
>
> return $dl;
>
> }
There's an easier way to calculate the days:
use Date::Calc qw/Delta_Days/;
print Delta_Days(2000,01,01, 2003,02,04);
There must be also a c library doing this job,
as this Perl module is based on one.
Greetings,
Janek
------------------------------
Date: Tue, 4 Feb 2003 10:27:52 +0000
From: news@roaima.freeserve.co.uk
Subject: Re: How to close all ports ???
Message-Id: <8j4o1b.657.ln@moldev.cmagroup.co.uk>
David Wayne <dwayne@hotmail.com> wrote:
> But I ran it and it sat there listening but I could not get my
> client-side program to connect, eventually I aborted the script and
> now get an internal error when trying to re-run it (with no changes),
Chris <news@roaima.freeserve.co.uk> commented:
> Ah. So it's a web server script? How do you know the process that's
> doing the socket listening has really ended? I suspect it hasn't.
David Wayne <Dwayne@hotmail.com> replied:
> LOL - Probably true - so how WOULD I know if it has stopped listening
> and how do I make it stop once it has started ???
You need to write some code that lets you determine whether another copy
of your program is still running or not, and depending on the result,
maybe shoot it down in flames.
One approach is:
1. Try to bind the socket
2a. If it succeeds,
3. You can probably assume there's no other program copy running
4. Write your PID to a lockfile
2b. If it fails,
5. Read the PID from the lockfile (if it exists) and kill it (SIGHUP)
7. In any case, wait a bit
8. Retry from (1)
3. Do your stuff
[...]
96. When your program ends
97. Delete the lockfile
98. Release the socket
99. Exit
In this scenario, the most recently started copy of the program will
always shut down older copies. This may or may not be what you want -
in which case you may have to modify the algorithm somewhat.
You may need your program to do some tidying up when it's killed. By
using SIGHUP, you can install a SIGHUP handler.
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: 4 Feb 2003 02:17:29 -0800
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Re: Need OS-independent module for starting "fire-and-forget" script
Message-Id: <d27434e.0302040217.4627bc6@posting.google.com>
Simon Andrews <simon.andrews@bbsrc.ac.uk> wrote in message news:<3E39516C.D32C385@bbsrc.ac.uk>...
>
> John Ramsden wrote:
> >
> > I am writing a monitoring tool in Perl and need a simple function to
> > start a background script running and then carry on, with no further
> > interaction with that script (i.e. no signals on its completion, and
> > certainly no mixed up input and output!)
> >
> > Furthermore, this "fire-and-forget" script startup must work in both
> > Unix and Windows.
> >
> > [...]
>
> if ($^O =~ /Win/i) {
> system ('start prog.exe');
> }
Ah, thanks. Since posting my question I was digging around for info
on something else and came across a page devoted to Windows NT shell
scripting (similar to DOS, but uses 32-bit cmd.exe instead of 16-bit
command.com).
As it may be relevant to people using Perl on Windows, I'll just add
that in Windows the best way to start a 'fire & forget' command is a
slight elaboration of the above, i.e.:
system ('start "Title" cmd /c my_command_and_args');
where "title" is the command title shown while the command is running,
'cmd' starts an instance of cmd.exe, and /c tells cmd.exe to close the
process when the command completes (which isn't the default,
strangely),
e.g. to send a text message to someone's mobile phone:
system ('start "SMS" cmd /c SMSMaster -aSue "C U L8ter Sue!"')
In case anyone finds it useful, the page on cmd.exe shell scripting
is at:
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/winntas/deploy/prodspecs/shellscr.asp
> else {
> system ('/usr/bin/prog &');
> }
Cheers
John Ramsden (john_ramsden@sagitta-ps.com)
------------------------------
Date: 4 Feb 2003 00:26:55 -0800
From: tecargile@hotmail.com (Tim Cargile)
Subject: Re: Parse a logfile - 1st column DateStamp; extract latest mods toan ItemNumber
Message-Id: <8b67aef5.0302040026.2ddb006b@posting.google.com>
Mina Naguib <spam@thecouch.homeip.net> wrote in message news:<DyE%9.26466$k52.435676@wagner.videotron.net>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Benjamin Goldberg wrote:
> | Mina Naguib wrote:
> | [snip]
> |
> |>| TimeStamp in YYYYMMDDHHMMSS
> |>| format|ItemNumber|Attribute1|Attribute2|Attribute3
> |>|
> |>| Sample Input File
> |>| 20020731114502|0144058Y01|CHRM|LHSG|MISC
> |>| 20030109174500|0144058Y01|PLAS|RHSG|MISC
> |
> | [snip]
> |
> |>If you want it sorted by the item id as in your "desired output":
> |>
> |>perl -naF'\|' -e '$i{$F[1]} = $_ if ($F[0] > $i{$F[1]});
> |>END {map {print $i{$_}} sort keys %i}' infilename > outfilename
> |
> |
> | There's no need for the map{} there:
> |
> | perl -naF'\|' \
> | -e '$i{$F[1]} = $_ if $F[0] > $i{$F[1]};'
> | -e 'END {print @i{sort keys %i}}' \
> | infilename > outfilename
> |
> | See perldoc perldata for more info on hash slices.
>
> Very clever. I've never used hash slices before. I like!
I like hash too! But gobbed, no sliced!
>
> Thanks Benjamin.
>
Ditto,
----- BEGIN TIM SIGNATURE -----
Tim
----- END TIM SIGNATURE -----
> =oeTt
------------------------------
Date: Tue, 04 Feb 2003 09:15:52 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: perl simple script
Message-Id: <pan.2003.02.04.08.15.00.371881@kamelfreund.de>
On Mon, 03 Feb 2003 10:09:15 -0800, zr wrote:
> It was 'suggested' by the client to do it in perl, and I was told
> perl's regexp is more powerfull than grep's (the regexp can be
> complicated). But maybe it could work just with a grep...
You should also have a look to the Perl Power Tools
(http://search.cpan.org?query=PPT&mode=all)
There's a tcgrep tool that is similar to unix grep, but with Perl regexps.
But to say the truth, I'm wondering about the client. Unless he/she is a
Perl regexp master, the more power of Perl's regexps isn't really useful.
And if he/she is, it's a simple one ... three liner, I wouldn't pay
anybody to do it!
> Thanks to all (not to you, Tassilo, get a life), I guess I will use
> Tonys 1 line code.
I'm sure Tassilo has a life. But, he also uses a lot of his time to
help people finding _good_ solutions without any credit in this newsgroup.
You really can take him serious. In fact, I had the same opinion like him!
Cheerio,
Janek
------------------------------
Date: 3 Feb 2003 21:49:09 -0800
From: flateyjarbok@yahoo.com (R Solberg)
Subject: Re: read web content
Message-Id: <386cc483.0302032149.14d5b4bb@posting.google.com>
"Pons" <pons@gmx.li> wrote in message news:<b1itlq$13i7go$1@ID-172702.news.dfncis.de>...
> I would like to write a script to read the content of
> Web page, and copy it to a file *.txt for later use
> such as filtering or putting it in a string?
> can any one help? if not ignore me !
>
>
> -Pons
> pons@gmx.li
How do I get at a URL if the site is protected by a password (and I
have a legitimate password. I know there are different types of
security, so for example can anyone explain with code how to access
wsj.com web pages?
------------------------------
Date: 4 Feb 2003 07:27:16 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: sort, my concoction of
Message-Id: <b1nq0k$njt$1@nets3.rz.RWTH-Aachen.DE>
Also sprach istink:
> my concoction of sort. It *seems* to work. what do you think.
>
> my flatfile:
>
> @db equals:
> 1|d|h|c|3|w
> 2|d|h|6|t|4
> 3|d|s|6|3|r
[...]
> I'm sorting the last column, column 5 (you know, 0,1,2,3,4,5)
[...]
> I want it to strip all non alpha/num
> and sort it.
> I want:
> jaj
> j(bh
> jce
>
>
> here's my experiment:
> @temp = sort {
> my $aa=(split '\|',uc($a), 6)[5];
> my $bb=(split '\|',uc($b), 6)[5];
> $aa=~ s/\W+//g;
> $bb=~ s/\W+//g;
> $aa cmp $bb;
> } @db;
> @db=@temp;
> it *seem* to work, but do you see any problems with it?
> as you can see I've avoided the complicate bubble sort.
It is certainly much better than your previous attempt with a
hand rolled bubble-sort.
> any potential problems with it?
> can it be made shorter? more efficent way?
It is still not as efficient as it could be. When using Perl's sort()
keep one thing in mind: the code-block is executed between n*log(n)
up to n**2 times for the bad cases (such as data already sorted) [1]. So
for each of these executions you do the split()s and the substitution.
But you can do the preprocessing only once for each element using a
Schwartzian Transform and then sort the thusly preprocessed data:
-1- @temp = map { $_->[0] }
-2- sort { $a->[1] cmp $b->[1] }
-3- map { my $last = (split /\|/)[-1];
-4- $last =~ tr/a-z//cd;
-5- [ $_, $last ] } @db;
You have to read that backwards. Line 3-5 turn the data into a list of
array-references. After that it will look like:
( [ "1|d|h|c|3|w", "w" ],
[ "2|d|h|6|t|4", "" ],
[ "3|d|s|6|3|r", "r" ],
...
)
You see that the first element of these referenced arrays is the
original data.
Line 2 now only compares $a->[1] and $b->[1]. For the two first elements
in this intermediate list this would be
"w" cmp ""
Line 1 now restores the original data as stored in the first element by
returning $_->[0].
I did some other minor things to speed up your sorting: I am using tr///
instead of s///. Whenever you can use tr/// you should prefer it over
s/// since it does not involve regular expressions but is just a
transliteration of characters. Secondly, I don't think you need the
uc(). If your data however contain upper-case characters you have to
change my code slightly:
...
map { my $last = uc( (split /\|/)[-1] );
$last =~ tr/A-Z//cd;
[ $_, $last ] } @db;
> what is the purpose of life?
Sorry, can't help you with that. But one purpose could be reading the
material that Uri has given you (see his reply). He has written a nice
article on different sorting techniques. I think it also discusses the
Schwartzian Transform, but he came up with another transformation which
is even quicker under some circumstances.
Tassilo
[1] Note that this is only true for perls < 5.8.0. Nowadays perl uses
merge-sort per default instead of quick-sort and merge-sort has a much
better worst case behaviour (it's always O( n*log(n) ). Apart from that
it has the benefit of being a stable sort.
If you are already using perl5.8.0 you can do some experiments by
switching from one sort algorithm to the other:
use sort '_quicksort';
# or
use sort '_mergesort';
Also see 'perldoc sort' that contains a short explanation of the
benefits of the respective algorithms.
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 4 Feb 2003 10:57:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: strange localtime return
Message-Id: <b1o6be$dl0$1@mamenchi.zrz.TU-Berlin.DE>
Shadowfax <shadowfax@optonline.net> wrote in comp.lang.perl.misc:
> Hi, All,
>
> I'm new to Perl/W32, I try to use below script to modify filenames
> under specific directory to make it looks like yyyymmdd_x. But when I
> run the script, surprisingly I saw the $year return as "691131", did I
> do something wrong ?
>
> Perl Script:
Before you present a script, make it run under strict and warnings.
> $org_dir="E:\\temp\\testfolder";
>
> opendir(DIR,$org_dir)||die "can't open original directory $org_dir" ;
> @org_files=readdir(DIR) ;
> closedir(DIR) ;
>
> foreach $org_file(@org_files)
> {
> $mtime=(stat($org_file))[9] ;
stat() won't normally find the file named $org_file, it's in $org_dir,
not in your current directory. So $mtime is very likely undefined.
Try "$org_dir/$org_file".
> my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime
> mtime;
"$" missing before "mtime". But, as mentioned, $mtime is undef. Under
strict and warnings you would have seen quite some comments under this
situation.
I'm stopping here. Try again with strict and warnings enabled.
[snip]
Anno
------------------------------
Date: 4 Feb 2003 01:57:49 -0800
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Re: Tainting individual variables
Message-Id: <d27434e.0302040157.4fcffcda@posting.google.com>
Brian McCauley <nobull@mail.com> wrote in message news:<u965s9w316.fsf@wcl-l.bham.ac.uk>...
>
> [...]
>
> use String::Interpolate;
> my $i = safe String::Interpolate {
> msg_severity => \$msg_severity,
> device_name => \$device_name,
> };
>
> my $alert = $i->($boiler_plate);
Many thanks, Brian, and to everyone else who replied.
That certainly sounds like the thing to use.
Cheers
John Ramsden (john_ramsden@sagitta-ps.com)
------------------------------
Date: 3 Feb 2003 22:16:07 -0800
From: paulhefford@hotmail.com (Paul)
Subject: Until loop not working with multiple conditions
Message-Id: <40b39fd3.0302032216.78ee7106@posting.google.com>
Can someone tell me why this until loop is not working in perl?
$param="N";
$count=1;
until($count==5 || $param=="Y") {
print "count = $count\n";
$count++;
}
I can only get the until loop to work if there is ONE conditional
expresson. For example,
$count=1;
until($count==5) {
print "count = $count\n";
$count++;
}
I just cannot get multiple conditions to work. I need to use multiple
conditional expressions! What am I doing wrong?
------------------------------
Date: Tue, 4 Feb 2003 06:47:23 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Until loop not working with multiple conditions
Message-Id: <Xns93184E9A948A4elhber1lidotechnet@62.89.127.66>
Paul wrote:
> Can someone tell me why this until loop is not working in perl?
>
> $param="N";
> $count=1;
> until($count==5 || $param=="Y") {
Change
$param == "Y"
to
$param eq 'Y'
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Tue, 04 Feb 2003 06:53:32 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Until loop not working with multiple conditions
Message-Id: <mbudash-1C62A4.22533103022003@typhoon.sonic.net>
In article <40b39fd3.0302032216.78ee7106@posting.google.com>,
paulhefford@hotmail.com (Paul) wrote:
> Can someone tell me why this until loop is not working in perl?
>
> $param="N";
> $count=1;
> until($count==5 || $param=="Y") {
^^------- s/b "eq"
[snip]
hth-
------------------------------
Date: Tue, 04 Feb 2003 10:22:21 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Until loop not working with multiple conditions
Message-Id: <pan.2003.02.04.08.21.02.960390@kamelfreund.de>
On Mon, 03 Feb 2003 22:16:07 -0800, Paul wrote:
> Can someone tell me why this until loop is not working in perl?
>
> $param="N";
> $count=1;
> until($count==5 || $param=="Y") {
^^
As already noted by some others :-)
Perl would have warned you about, if you would have used
the next both lines at the beginning of your script:
use strict;
use warnings;
> print "count = $count\n";
> $count++;
> }
>
> I can only get the until loop to work if there is ONE conditional
> expresson. For example,
>
> $count=1;
> until($count==5) {
> print "count = $count\n";
> $count++;
> }
>
That's a point where it is unlogical to use an until loop (in Perl, some
other languages lack in their possibilities to express what the programmer
meant).
You just want to run a block 5 times and leave it sometimes a bit earlier. A
better way to express it is to use a for loop with a breaking statement:
for my $count (1 .. 5) {
last if $param eq 'Y';
# ...
# ...
print "count = $count\n";
}
Best Wishes,
Janek
------------------------------
Date: Tue, 04 Feb 2003 11:01:46 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Until loop not working with multiple conditions
Message-Id: <u4N%9.2410$MI5.886@nwrddc01.gnilink.net>
Janek Schleicher wrote:
> On Mon, 03 Feb 2003 22:16:07 -0800, Paul wrote:
>
>> Can someone tell me why this until loop is not working in perl?
>>
>> $param="N";
>> $count=1;
>> until($count==5 || $param=="Y") {
[...]
> That's a point where it is unlogical to use an until loop (in Perl,
> some other languages lack in their possibilities to express what the
> programmer meant).
> You just want to run a block 5 times and leave it sometimes a bit
> earlier. A better way to express it is to use a for loop with a
> breaking statement:
>
> for my $count (1 .. 5) {
> last if $param eq 'Y';
> # ...
This is arguable. For the OPs version of the loop it's obvious how to find a
post condition.
I'm not sure how you would do that for your version of the loop.
But maybe you are not interested in program verification....
jue
------------------------------
Date: Tue, 04 Feb 2003 09:00:13 GMT
From: thumb_42@yahoo.com
Subject: Re: why does not this work
Message-Id: <wiL%9.159121$rM2.123124@rwcrnsc53>
classical music <ndescripto@yahoo.com> wrote:
> %a=%$b->{a}
>
> does not work.
>
> $a=$b->{a};
> %a=%$a
>
> works
>
> Is it expected? Why?
%a=%$b->{a}
Try:
%a=%{$b->{a}};
Jamie
------------------------------
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.
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 4509
***************************************