[29260] in Perl-Users-Digest
Perl-Users Digest, Issue: 504 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 11 16:09:59 2007
Date: Mon, 11 Jun 2007 13:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 11 Jun 2007 Volume: 11 Number: 504
Today's topics:
Re: a password encryption question. <glex_no-spam@qwest-spam-no.invalid>
Finding the right test that had an error when building <sigzero@gmail.com>
Re: Finding the right test that had an error when build (Greg Bacon)
lookahead bug (at least in 5.8.4) use63net@yahoo.com
Re: lookahead bug (at least in 5.8.4) <bart.lateur@pandora.be>
Re: lookahead bug (at least in 5.8.4) use63net@yahoo.com
Re: lookahead bug (at least in 5.8.4) xhoster@gmail.com
lwp:: what came before get joez3@yahoo.com
Re: lwp:: what came before get <glex_no-spam@qwest-spam-no.invalid>
Re: parallel child processes not working properly xhoster@gmail.com
Re: parallel child processes not working properly <glex_no-spam@qwest-spam-no.invalid>
Passing literal with reference? <dorno@whitehouse.com>
Re: Passing literal with reference? <mritty@gmail.com>
Re: Passing literal with reference? <mritty@gmail.com>
Re: Passing literal with reference? <dorno@whitehouse.com>
Re: Passing literal with reference? <mritty@gmail.com>
Re: Passing literal with reference? <noreply@gunnar.cc>
phone number backtracking <jtbutler78@comcast.net>
Re: phone number backtracking <noreply@gunnar.cc>
Re: phone number backtracking <jtbutler78@comcast.net>
Re: Useless use of array element in void context <mritty@gmail.com>
Re: Useless use of array element in void context <mstep@podiuminternational.org>
www.goxbuy.com Buy WoW gold RS gold WG k gold <eBankGame2010@gmail.com>
Re: Yet Another Software Challenge <bc@freeuk.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 Jun 2007 12:04:00 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: a password encryption question.
Message-Id: <466d8081$0$490$815e3792@news.qwest.net>
nightcats@gmail.com wrote:
> $pass = crypt($password, substr($password, 0, 2));
Just wanted to point out that no one should ever use parts of
the clear text password as the salt. Why? If someone gets
the encrypted password, then they already have the first two
letters of the clear text password, making it much easier to
crack.
------------------------------
Date: Mon, 11 Jun 2007 06:10:36 -0700
From: Robert Hicks <sigzero@gmail.com>
Subject: Finding the right test that had an error when building Perl
Message-Id: <1181567436.796120.299160@c77g2000hse.googlegroups.com>
I downloaded and Configured Perl 5.6.2 on an HP ia64 box. When running
a make test I get 1 error:
t/lib/b.............................FAILED at test 15
I have gone into that file...and I see no easy way to figure out which
is "test 15".
Robert
------------------------------
Date: Mon, 11 Jun 2007 16:05:10 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Finding the right test that had an error when building Perl
Message-Id: <136qslmli1eiha5@corp.supernews.com>
In article <1181567436.796120.299160@c77g2000hse.googlegroups.com>,
Robert Hicks <sigzero@gmail.com> wrote:
: I downloaded and Configured Perl 5.6.2 on an HP ia64 box. When running
: a make test I get 1 error:
:
: t/lib/b.............................FAILED at test 15
:
: I have gone into that file...and I see no easy way to figure out which
: is "test 15".
Look at the source and count calls to ok().
Did the test output have a comment that also helps pinpoint the
code for the failing test?
Hope this helps,
Greg
--
The U.S. government is skilled at levying -- just not so good at leveeing.
-- Gary North
------------------------------
Date: Mon, 11 Jun 2007 09:09:12 -0700
From: use63net@yahoo.com
Subject: lookahead bug (at least in 5.8.4)
Message-Id: <1181578152.143652.249300@g37g2000prf.googlegroups.com>
'ab' =~ /(?=.*a)b/; # How the heck is this false?
'ab' =~ /(?=a)b/; # Nope, but still looks like it should match
'Xab' =~ /(?=.*a)b/; # Nice try, but putting in any other characters
doesn't work.
'ab' =~ /(?=.*b)a/; # At least this matches as expected.
------------------------------
Date: Mon, 11 Jun 2007 16:27:15 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: lookahead bug (at least in 5.8.4)
Message-Id: <rgtq63hmntk8ivraq7sc7d2gv641j2io8j@4ax.com>
use63net@yahoo.com wrote:
>'ab' =~ /(?=.*a)b/; # How the heck is this false?
>'ab' =~ /(?=a)b/; # Nope, but still looks like it should match
>'Xab' =~ /(?=.*a)b/; # Nice try, but putting in any other characters
>doesn't work.
>
>'ab' =~ /(?=.*b)a/; # At least this matches as expected.
The bug is in you. Your expectations are wrong. Let's go over them one
at a time.
/(?=.*a)b/
In English: find a location where you can next match a "b", and where
somewhere down the line (looking from the front of the match), there's
an "a". So this means that there should be an "a" following the "b".
Nope, not in this string. So it doesn't match.
/(?=a)b/;
Find a location where you can match a "b", and where the next character
is "a". So this one character should be both an "a" and a "b". That
can't be, so it is always false.
'Xab' =~ /(?=.*a)b/;
There's still no "a" following the "b".
'ab' =~ /(?=.*b)a/
Yes, there is a 'b' further down where it matches an "a". So this
matches.
If you want to match both an "a" somewhere down the line, and ditto with
a "b", try
/(?=.*a)(?=.*b)/
or maybe better
/^(?=.*a)(?=.*b)/s
The /^/ is not absolutely necessary, but it'll prevent useless trying
over and over again on failure. Either it should work from the start of
the string, or it won't work at all.
--
Bart.
------------------------------
Date: Mon, 11 Jun 2007 10:56:10 -0700
From: use63net@yahoo.com
Subject: Re: lookahead bug (at least in 5.8.4)
Message-Id: <1181584570.954507.81610@g37g2000prf.googlegroups.com>
Nope, not my expectations. It's how I took it worked from the Perl
Cookbook - near the bottom of page 212:
-----------------
True if both /ALPHA/ and /BETA/ match, but may overlap ... like /
ALPHA/ && /BETA/"
/^(?=.*ALPHA)BETA/s
----------------
# I'd remove the "^", but it still doesn't match anything like
"ALPHABETA"
------------------------------
Date: 11 Jun 2007 18:24:27 GMT
From: xhoster@gmail.com
Subject: Re: lookahead bug (at least in 5.8.4)
Message-Id: <20070611142432.069$Em@newsreader.com>
use63net@yahoo.com wrote:
> Nope, not my expectations.
What is not your expectations? Please quote some context.
> It's how I took it worked from the Perl
> Cookbook - near the bottom of page 212:
> -----------------
> True if both /ALPHA/ and /BETA/ match, but may overlap ... like /
> ALPHA/ && /BETA/"
> /^(?=.*ALPHA)BETA/s
> ----------------
>
> # I'd remove the "^", but it still doesn't match anything like
> "ALPHABETA"
I think that newer versions of the Perl Cookbook has that fixed to
something like /^(?=.*ALPHA).*BETA/s. Anyway, if you try to understand
what those funny characters do, instead of just copying things by rote,
then you would not be so easily tripped up by other people's errors.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 11 Jun 2007 09:59:38 -0700
From: joez3@yahoo.com
Subject: lwp:: what came before get
Message-Id: <1181581178.148741.4190@g37g2000prf.googlegroups.com>
Hi,
I need to write a perl script using perl version 5.005 on windows to
download a file. I orginally wrote the perl scipt using a new version
of perl and LWP. I had line of code that was:
$response = $ua->get($downloadURL, ':content_file' => $storLocation);
I orginally wrote this on a system that had perl 5.6.1 and it worked
fine, but when I try to use this on the older perl it fails with:
Can't locate object method "get" via package "LWP::UserAgent" at
downloadvcclient.pl line 91.
So how can I rewite this to work with the older version of perl?
Thanks,
zim
------------------------------
Date: Mon, 11 Jun 2007 12:29:23 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: lwp:: what came before get
Message-Id: <466d8673$0$494$815e3792@news.qwest.net>
joez3@yahoo.com wrote:
> Hi,
> I need to write a perl script using perl version 5.005 on windows to
> download a file. I orginally wrote the perl scipt using a new version
> of perl and LWP. I had line of code that was:
> $response = $ua->get($downloadURL, ':content_file' => $storLocation);
> I orginally wrote this on a system that had perl 5.6.1 and it worked
> fine, but when I try to use this on the older perl it fails with:
> Can't locate object method "get" via package "LWP::UserAgent" at
> downloadvcclient.pl line 91.
> So how can I rewite this to work with the older version of perl?
ahhhh.. look at the documentation for the version of LWP::UserAgent
you have installed... It is installed, right?
perldoc LWP::UserAgent
------------------------------
Date: 11 Jun 2007 16:42:17 GMT
From: xhoster@gmail.com
Subject: Re: parallel child processes not working properly
Message-Id: <20070611124221.489$g7@newsreader.com>
vkinger@hotmail.com wrote:
> Hi,
>
> I have a problem where I am creating multiple parallel child processes
> to connect to multiple servers. Each child process has a different
> filehandle to read starttime from a text file at the time of fork and
> then write into this text file each time it runs. Each child process
> has a forever loop so that it never exits unless killed or reboot
> occured at server and then it tries to reconnect.
How does the no longer existent child process try to reconnect?
> My problem is it
> works for couple of times and logs data from different servers into
> syslog but on 2nd or 3rd attempt(after being stopped by kill -9
> <process id>)
What is killed by kill -9, the parent or the child or something else? And
why -9?
> it only works with the one server( it can be 1st or 2nd
> or 3rd as I am testing with only three servers at present)
What do you mean by "works" in this case?
> I am not
> sure what is wrong, may be I can use some help here from the experts.
> Here is what I am doing.
>
> sub fork_pids
> {
> my @pids;
This variable doesn't seem to be used.
> my $i = 0;
premature declaration, no?
> my $length = scalar(@lines);
> my $pm = new Parallel::ForkManager($length);
> print " Connecting to " , $length , " servers\n ";
> for $i ( 1 .. $length )
> {
> print "spawning child processes $i\n";
How many of these get printed?
> $pm->start and next; #do the fork
> print "Inside the child process\n";
How many of these get printed?
> &GetEventData($i-1);
> $pm->finish;
> }
> $pm->wait_all_children;
> }
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 11 Jun 2007 11:56:43 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: parallel child processes not working properly
Message-Id: <466d7ecb$0$508$815e3792@news.qwest.net>
vkinger@hotmail.com wrote:
> Hi,
>
> I have a problem where I am creating multiple parallel child processes
> to connect to multiple servers. [...] My problem is it
> works for couple of times and logs data from different servers into
> syslog but on 2nd or 3rd attempt(after being stopped by kill -9
> <process id>) it only works with the one server( it can be 1st or 2nd
> or 3rd as I am testing with only three servers at present) I am not
> sure what is wrong, may be I can use some help here from the experts.
> Here is what I am doing.
>
> sub fork_pids
> {
> my @pids;
@pids isn't used..
> my $i = 0;
No need for that.
> my $length = scalar(@lines);
No need for 'scalar'.
> my $pm = new Parallel::ForkManager($length);
> print " Connecting to " , $length , " servers\n ";
> for $i ( 1 .. $length )
for my $i ( 1 .. $length )
> {
> print "spawning child processes $i\n";
> $pm->start and next; #do the fork
> print "Inside the child process\n";
> &GetEventData($i-1);
Probably want to call GetEventData( $i - 1 ) there.
> $pm->finish;
> }
> $pm->wait_all_children;
> }
Nothing wrong with that, so it must be in another part of your code.
------------------------------
Date: Mon, 11 Jun 2007 13:03:35 -0500
From: dorno <dorno@whitehouse.com>
Subject: Passing literal with reference?
Message-Id: <pan.2007.06.11.18.03.35.269005@whitehouse.com>
Passing variables to a subroutine by reference is covered in depth by any
of the books. Like this...
myroutine(\$var1, \@array1, \%hash1);
sub myroutine {
my($scalar, array, hash) = @_;
}
All the variables get to the subroutine intact and no problem.
But if I want to change the $scalar to a literal, like so.
myroutine("myvariable", \@array1, \%hash1);
It hoses the call and attaches the literal as a member of the array.
To make it work I have to...
my $var1 = "myvariable";
myroutine(\$var1, \@array1, \%hash1);
which takes it back to square one. No problem there, it works, but I was
wondering if there is a way to pass a bare literal with other references?
There has to be - in fact with Perl there is probably a dozen ways. But
my trying and reading hasn't found it yet. This is one of those things
that the more I try the behinder I get.
Thanks any
dorno
------------------------------
Date: Mon, 11 Jun 2007 11:21:03 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Passing literal with reference?
Message-Id: <1181586063.821254.224630@q75g2000hsh.googlegroups.com>
On Jun 11, 2:03 pm, dorno <d...@whitehouse.com> wrote:
> Passing variables to a subroutine by reference is
> covered in depth by any of the books. Like this...
>
> myroutine(\$var1, \@array1, \%hash1);
>
> sub myroutine {
> my($scalar, array, hash) = @_;
Presumably, you meant $array and $hash. . .
>
> }
>
> All the variables get to the subroutine intact and no problem.
>
> But if I want to change the $scalar to a literal, like so.
>
> myroutine("myvariable", \@array1, \%hash1);
>
> It hoses the call and attaches the literal as a member of the array.
>
> To make it work I have to...
>
> my $var1 = "myvariable";
> myroutine(\$var1, \@array1, \%hash1);
>
> which takes it back to square one. No problem there, it works, but I was
> wondering if there is a way to pass a bare literal with other references?
> There has to be - in fact with Perl there is probably a dozen ways. But
> my trying and reading hasn't found it yet. This is one of those things
> that the more I try the behinder I get.
I do not believe you can create a reference to a literal, regardless
of what you want to do with it. I have to ask.... what are you
*trying* to do? That is, what problem are you trying to solve, the
solution to which you've decided is to pass a reference to a literal?
There are three usual reasons one passes a reference to a variable to
a subroutine, rather than the actual variable itself:
1) You wish to make changes to the variable within the subroutine, but
don't want to be stuck with difficult-to-interpet code like
$_[0] = 'newvalue';
2) The variable is a hash or array, and so will be "flattened" into @_
if it's passed directly, rendering you unable to use the actual hash/
array's values.
3) For efficiency, so you don't have to make a copy of a huge value
every time you call the subroutine.
In this case, (1) doesn't apply because you can't "change" a literal
anyway. (2) doesn't apply, because you're talking about a scalar
value. So the only thing I can think is that you're trying to gain an
imperceptable efficiency improvement by avoiding the copy of the
string. Is that correct?
Paul Lalli
------------------------------
Date: Mon, 11 Jun 2007 11:22:52 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Passing literal with reference?
Message-Id: <1181586172.571790.96370@p47g2000hsd.googlegroups.com>
On Jun 11, 2:03 pm, dorno <d...@whitehouse.com> wrote:
> Passing variables to a subroutine by reference is covered in depth by any
> of the books. Like this...
>
> myroutine(\$var1, \@array1, \%hash1);
>
> sub myroutine {
> my($scalar, array, hash) = @_;
>
> }
>
> All the variables get to the subroutine intact and no problem.
>
> But if I want to change the $scalar to a literal, like so.
>
> myroutine("myvariable", \@array1, \%hash1);
>
> It hoses the call and attaches the literal as a member of the array.
I should have also asked: What do you mean by this? How is the call
"hosed"? How is it "attached as a member of the array"? If this is
your call, and your subroutine still starts out as:
my ($scalar, $array, $hash) = @_;
then $scalar has the value "myvariable", $array has a reference to
@array1, and $hash has a reference to $hash1.
What is the problem with this example?
Paul Lalli
------------------------------
Date: Mon, 11 Jun 2007 14:37:14 -0500
From: dorno <dorno@whitehouse.com>
Subject: Re: Passing literal with reference?
Message-Id: <pan.2007.06.11.19.37.13.369015@whitehouse.com>
>
> Presumably, you meant $array and $hash. . .
Yep. A typo on my part. Comes from recreating a problem on my machine
at the office that is really happening on my PC at home.
>
> I do not believe you can create a reference to a literal, regardless
> of what you want to do with it. I have to ask.... what are you
> *trying* to do? That is, what problem are you trying to solve, the
> solution to which you've decided is to pass a reference to a literal?
I had a feeling that a literal couldn't be referenced. But... Perl has so
many ways to do stuff that I never imagined could be done that I was
hoping.
Anyway, if I can make my request somewhat more clear.
Passing \$var, \@array and \%hash keeps the entire batch from being
flattened. Works fine and they come out in the subroutine seperate and
ready to go.
But sometimes, instead of $var, I just want to pass a literal instead of
initalizing a variable and then passing that. In that case, the whole
batch is partially "flattened" with "literal" becoming part of whatever
is next in the parameter string, in this case @array. It isn't a show
stopper but is rather an inconvenience. A lot of times one of my calls
has multiple scalars and a single hash or array and the parameters never
change. So I either have to suck them out of the array they have been
flattened into, or build a my $var1, my $var2, etc and pass them that way.
Or put the scalars into an array and pass that properly.
The other problem is that if I code the subroutine to handle a referenced
set of parameters, a flattening of the parameters blows the code Unless I
test and handle both (or three, or four...) cases in which case the
handling routine usually would become more complex than the subroutine
itself.
> value. So the only thing I can think is that you're trying to gain an
> imperceptable efficiency improvement by avoiding the copy of the
> string. Is that correct?
>
Not really efficiency in runtime, rather efficiency in reading the code
later. A glance at callroutine('Swords','Short','Bronze','100');
is easier to grasp than looking at
callroutine(\$table,\$size,\$type,\cost); then scrolling up to the
variable list and checking out what each parameter is supposed to be.
Actually, it is more along the lines of even though I have been using Perl for
several years in a simplistic mode (i.e. enough to make Linux work), I am
trying to actually learn how to code in Perl properly.
Thanks
dorno
------------------------------
Date: Mon, 11 Jun 2007 12:59:43 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Passing literal with reference?
Message-Id: <1181591983.778856.166110@u2g2000hsc.googlegroups.com>
On Jun 11, 3:37 pm, dorno <d...@whitehouse.com> wrote:
> Anyway, if I can make my request somewhat more clear.
>
> Passing \$var, \@array and \%hash keeps the entire batch from being
> flattened. Works fine and they come out in the subroutine seperate
> and ready to go.
>
> But sometimes, instead of $var, I just want to pass a literal
> instead of initalizing a variable and then passing that. In that
> case, the whole batch is partially "flattened" with "literal"
> becoming part of whatever is next in the parameter string, in this
> case @array.
No, it really really doesn't. Can you show an example where you think
this is happening? Here's my counter example:
$ perl -le'
sub myroutine {
my ($s, $a, $h) = @_;
print "Scalar: $s";
print "Array: @$a";
print "Hash: ", join (", ", map { "$_ => $h->{$_}" } keys %$h);
}
my @a = (1..5);
my %h = (a => 1, b => 2, c => 3, d => 4, e => 5);
myroutine("string", \@a, \%h);
'
Scalar: string
Array: 1 2 3 4 5
Hash: e => 5, c => 3, a => 1, b => 2, d => 4
Paul Lalli
------------------------------
Date: Mon, 11 Jun 2007 22:04:46 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Passing literal with reference?
Message-Id: <5d5oc6F32rb0qU1@mid.individual.net>
Paul Lalli wrote:
> I do not believe you can create a reference to a literal, regardless
> of what you want to do with it.
Why do you say that? The code below prints "myvariable" just as I would
have expected:
sub myroutine {
my $ref = shift;
print $$ref;
}
myroutine( \'myvariable' );
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 11 Jun 2007 06:44:55 -0700
From: "jtbutler78@comcast.net" <jtbutler78@comcast.net>
Subject: phone number backtracking
Message-Id: <1181569495.969189.254280@w5g2000hsg.googlegroups.com>
I was wondering if anyone knew how to get the digits out of a phone
number where the area code is optional. I have a feeling that there
is backtracking involved but I am not sure. Anyone have any ideas?
This is what I have so far - it works for 10 digits not 7.
$phone = '123-123-1234';
$phone = '123-1234';
($area_cd,$prefix,$extension) = $phone =~ /(?<=(\d{3}) \-) (\d{3}) \-
(\d{4}) /x;
------------------------------
Date: Mon, 11 Jun 2007 16:34:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: phone number backtracking
Message-Id: <5d5508F334he0U1@mid.individual.net>
jtbutler78@comcast.net wrote:
> I was wondering if anyone knew how to get the digits out of a phone
> number where the area code is optional. I have a feeling that there
> is backtracking involved but I am not sure. Anyone have any ideas?
>
> This is what I have so far - it works for 10 digits not 7.
> $phone = '123-123-1234';
> $phone = '123-1234';
>
> ($area_cd,$prefix,$extension) = $phone =~ /(?<=(\d{3}) \-) (\d{3}) \-
> (\d{4}) /x;
What you tried is called a zero-width positive look-behind assertion. I
can't see why that would be needed; simple non-capturing parentheses and
the ? quantifier should do.
Try:
/(?:(\d{3})-)?(\d{3})-(\d{4})/;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 11 Jun 2007 07:44:28 -0700
From: "jtbutler78@comcast.net" <jtbutler78@comcast.net>
Subject: Re: phone number backtracking
Message-Id: <1181573068.987170.4390@p77g2000hsh.googlegroups.com>
On Jun 11, 10:34 am, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> jtbutle...@comcast.net wrote:
> > I was wondering if anyone knew how to get the digits out of a phone
> > number where the area code is optional. I have a feeling that there
> > is backtracking involved but I am not sure. Anyone have any ideas?
>
> > This is what I have so far - it works for 10 digits not 7.
> > $phone = '123-123-1234';
> > $phone = '123-1234';
>
> > ($area_cd,$prefix,$extension) = $phone =~ /(?<=(\d{3}) \-) (\d{3}) \-
> > (\d{4}) /x;
>
> What you tried is called a zero-width positive look-behind assertion. I
> can't see why that would be needed; simple non-capturing parentheses and
> the ? quantifier should do.
>
> Try:
>
> /(?:(\d{3})-)?(\d{3})-(\d{4})/;
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl
Thanks. I actually found something similar after I posted this. You
solution is better then the one I can up with.
------------------------------
Date: Mon, 11 Jun 2007 03:36:14 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Useless use of array element in void context
Message-Id: <1181558174.301220.254110@m36g2000hse.googlegroups.com>
On Jun 11, 4:48 am, Marek <m...@podiuminternational.org> wrote:
> Thank you Peter!
>
> correction to my previous posting:
>
> printf( "TOTAL\t\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n",
> @result[2..6] );
>
> => @result[0..4]
>
> of course! Little question to you more: you suggested:
>
> my $same = 1;
> $same = $same && $old_line[$_] == $out_line[$_] for (2 .. 6);
> if ($same) { ... }
>
> I changed to:
>
> my $same = 1;
> $same = $old_line[$_] == $out_line[$_] for (2 .. 6);
> if ($same) { ... }
>
> because I did not understand the use of the second "$same" after "="
> Is it really needed?
Yes it is. Your example is only giving the result of the final
comparison. It is completely ignoring indices two through five.
In Peter's original, $same is being set to the result of the
conjunction of $same and the current comparison. As an example:
$same starts as 1
The arrays at index 2 are equal, so the comparison returns 1.
1 && 1 = 1, so $same stays one.
The arrays at index 3 are not equal, so the comparison returns 0.
1 && 0 = 0, so $same becomes 0.
The arrays at index 4 are equal, so the comparison returns 1.
0 && 1 = 0, so $same stays 0. In your example, however, $same becomes
1, completely ignoring the fact that at index 3, the arrays were not
equal.
Paul Lalli
------------------------------
Date: Mon, 11 Jun 2007 06:59:29 -0700
From: Marek <mstep@podiuminternational.org>
Subject: Re: Useless use of array element in void context
Message-Id: <1181570369.867650.56550@k79g2000hse.googlegroups.com>
Thank you Paul, your explanations are very clear. Great to have such
help in this group!
greetings
marek
------------------------------
Date: Mon, 11 Jun 2007 12:27:22 -0700
From: "ebankgame.com" <eBankGame2010@gmail.com>
Subject: www.goxbuy.com Buy WoW gold RS gold WG k gold
Message-Id: <1181590042.644153.196900@z28g2000prd.googlegroups.com>
www.goxbuy.com Buy WoW gold RS gold WG k gold
1.The Fastest Delivery Speed on all Servers in 1-8 hours since your
payment arrives.If the deliver is delayed over 8 hours, you will get
5% extra gold for the late.Or you can request a refund.
2.Special Discount Servers.Sometimes, there will be some servers,
with
special discounts, with extremely NICE PRice on some certain servers.
3.Perfect Service.24 hours service with various contact methods: MSN,
ICQ, Online Chat on Web homepage,Welcome to www.goxbuy.com
If any problem, please contact us asap!
Happy shopping!
Sincerely,
www.goxbuy.com
ICQ:468873592
Choose your game
World of Warcraft EU
World of Warcraft US
Lord of The Rings EU
Lord of The Rings US
Lineage II
EverQuest2
Guild Wars
Final Fantacy XI
Runescape 2
RFO Online
Dungeons & Dragons Online
Eve Online
Star Wars Galaxies
go to www.goxbuy.com
------------------------------
Date: Mon, 11 Jun 2007 04:27:23 -0700
From: Bart <bc@freeuk.com>
Subject: Re: Yet Another Software Challenge
Message-Id: <1181561243.241900.267860@p77g2000hsh.googlegroups.com>
On Jun 11, 2:40 am, Joe Smith <j...@inwap.com> wrote:
> Bart wrote:
> > On Jun 7, 5:23 pm, yan...@gmail.com wrote:
>
> >> You're absolutely wrong! Where to start is clearly shown. Thousands of
> >> people have succeed so far..
>
> > I give up. What do you have to do to get started? Solve the riddle of
> > the salmon then stick that on the end of the url?
>
> > By 'clearly shown' I would expect a big button saying 'Start Here'.
>
> There IS a big button for 'Start Here'. It's 200 pixels wide and 49 high.
Thanks. That used to just show a bigger version, today it does
nothing. But finally I can see that ignition.jpg is not the same as
ignition.html.
Now I get a picture of a French chateau as you tend to do in
programming puzzles..
Bart
------------------------------
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 V11 Issue 504
**************************************