Man, this is exactly what people mean when they say Perl is unreadable. It
doesn't have to be. Any self-respecting Perl developer, especially one who
has read Perl Best Practices by Damian Conway, would never write this kind
of code.

Not long ago, Steve proclaimed...
> 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
> );

It's creating a name-value pair for each number in the map input sequence
(-9 to 9). The && basically says if the left argument is false, then the
right argument isn't even evaluaed. 

> 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.

The % is a literal % inside a string. The value side of the hash values
essentially evaluates to a string except when the sequence input value ($_)
is 0. 

Run this right after that code:

    use Data::Dumper;
    print Dumper(\%x);

-=Fozz

-- 
[EMAIL PROTECTED] is Doran L. "Fozz" Barton
 "We are ecologically minded. This package will self-destruct in Mother
  Earth."
    -- Seen on a Japan package

Attachment: pgpzTQAUwm9ob.pgp
Description: PGP signature

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to