[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Need a little confusion?



At 06:38 PM 5/10/01 +0200, Sven Neuhaus wrote:
>Hi,
>
>let me share my pain with you.. :-)
>Predict the output of the following script:
>
>========
>sub x {
>         my @a;
>         my $b = [ qw(a b c) ];
>         return [
>                 map { [ '??', $_ ] } @a,
>                 map { $_; } @$b
>         ];
>}
>
>use Data::Dumper;
>print Dumper(x());
>=========
>
>Nasty trap I fell into there..

I hate to sound like a know-it all, but I found the output easy to predict 
and I don't see what trap you fell into... what were you expecting?  The 
only thing I can think of is not seeing that the result of the second map 
becomes part of the list input to the first one, but since the second map 
is a noop anyway...


--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe