Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Map Function Weirdness

by ikegami (Patriarch)
on Nov 09, 2011 at 17:56 UTC ( [id://937167]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Map Function Weirdness
in thread Map Function Weirdness

Keep in mind that Deparse is not precise. It's a useful tool, but don't rely on it too deeply. For example, this is wrong.

>perl -MO=Deparse,-x9 -e"if(my $x=$a<$b){$a;}" my $x = $a < $b and do { $a }; -e syntax OK

The $x is scoped to the if. Or is it...

My code is an approximation too. The if is equivalent to neither

do { ( $a < $b ) and do { $a } };

nor

( $a < $b ) and do { $a };

The my is lexically scoped at compile-time (as shown in mine), but it's not lexically scoped at run-time (as shown by Concise and Deparse). This means the objects can live a little longer than expected.

... { ... if (my $obj = ...) { ... } . . # $obj still exists here "anonymously". . } # $obj cleared here, so destructor only called here. ...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://937167]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-25 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found