Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Spot the bug!

by Anonymous Monk
on Oct 26, 2006 at 07:13 UTC ( [id://580696]=note: print w/replies, xml ) Need Help??


in reply to Spot the bug!

Red herrings, and a wrong conclusion. It has nothing to do with either @_, or eval. It all has to do with Perl using pass by alias.
#!/usr/bin/perl use strict; use warnings; my $n; sub foo { $n = 0; return $_[0]; } print foo(3), "\n"; $n = 3; print foo($n), "\n"; __END__ 3 0
$_[0] is just a different name for $n, which is being modified in foo, just like your function uses eval, which sets $@.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-24 16:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found