Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^6: Perl bug ?

by tinita (Parson)
on Feb 06, 2013 at 13:20 UTC ( #1017422=note: print w/replies, xml ) Need Help??

in reply to Re^5: Perl bug ?
in thread Perl bug ?

seems like the arguments for "for" are executed first and then the loop body. so:
the first element is $e && 0 which evaluates to $e. then the second argument is processed, autovivify happens.
when in the loop body, $e is an array reference already, and because the first element is an alias to $e it prints ARRAY(0xde0d48). seems logical to me.

Replies are listed 'Best First'.
Re^7: Perl bug ?
by Corion (Pope) on Feb 06, 2013 at 13:23 UTC

    Yes. B::Deparse shows the same interpretation:

    Q:\>perl -MO=Deparse -E "my $e; say for $e && 0, $e->[0];" BEGIN { $^H{'feature_unicode'} = q(1); $^H{'feature_say'} = q(1); $^H{'feature_state'} = q(1); $^H{'feature_switch'} = q(1); } my $e; ; say $_ foreach ($e && 0, $$e[0]); -e syntax OK

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017422]
[Discipulus]: Tanktalus we will be glad to have you here more frequently, tho ;=)
[marioroy]: Lady_Aleena oh I thought you found the error by adding -exec mp3info
[Tanktalus]: Discipulus: I should be working on an interview test right now. Well, I kind of am, but keep getting myself distracted :)
[Lady_Aleena]: marioroy, nope, that IS the error.
[Discipulus]: oh to be distracted PM is still a wonderfull place
[Tanktalus]: Problem is, it's a test for another monk - as in, another monk letting me interview for his company :)
[Tanktalus]: He might see me here... :D
[Discipulus]: it's me? ;=)

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2017-04-23 19:57 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (432 votes). Check out past polls.