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

Re: [FWP] Need a little confusion?



>From fwp-l Thu May 10 11:26:39 2001

--- Sven Neuhaus <sn@neopoly.com> 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..
>
> -Sven

I may be missing something, but I don't see any "trap" in there.

Since @a will be an empty array, the sub x should return
a ref to an array of of three array refs each containing
the string '??' and one of the elements of @$b.

What am I thinking wrong?

/prakash

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

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