Brushing up on Perl?

Steve smorrey at gmail.com
Thu Jan 10 10:30:53 MST 2008


Hi everyone,

After my last debate on whether or not Perl was worth spending time to
sharpen my skills on.
I decided to start strengthing my neglected skills in this language.

I am presently working through some example code and am quite stuck on
a line of code and since there are no answers at the back of the book,
I'm not quite sure what this line is doing.

The line I'm stuck on is this...
($_, $_ && "$l%")

The code in it's context is this...
my %x =
(
	map {
		 my $l = $_ < 0
		 ? (($_ + 10) * 10)
		 : (($_ + 1) * 100);

	 	($_, $_ && "$l%")
	} -9 .. 9
);

Now I see that it's creating a hash.
It does so by counting in a loop fron -9 to +9
It first checks to see if $_ (Some number between -9 and +9) is < 0
If it is then $l = ($_+10)*10 else $l = ($_+1)*100
But the next line has me baffled.
I see that it's creating a hash with the 2 values, the first is of
course the number in question, but that second value has got me
stumped.
Is it really saying the second value is the modulus of number in
question and $l ?  Or is it something else?  I've never seen && used
in this way before.

Any ideas guys?

Thanks for the helps!

Sincerely,
Steve



More information about the PLUG mailing list