Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: scoping question

by ikegami (Pope)
on Mar 02, 2006 at 16:47 UTC ( #533971=note: print w/replies, xml ) Need Help??


in reply to Re: scoping question
in thread scoping question

Don't assign to $_ without localizing it first! $_ is usually aliased to another variable, and your code would clobber it. The fix is to add local to the first assignment (as shown below). However, if you do that, you've gained nothing but obfuscation. You should use my $id instead of local $_.
if ( local $_ = $obj->get_id() ) # XXX Use "my $id =" instead of { # "local $_ =" for clarity. $obj->do_this(); } elsif ( $_ = $obj->create_id() ) # XXX Use "$id =" instead of { # "$_ =" for clarity. $obj->do_that(); } else { $obj->do_somethingelse(); }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://533971]
help
Chatterbox?
[tye]: -1 means nobody logged in or the process was started before audit got booted
[davido]: ok, on my ubuntu system getlogin grabs from /proc/self/ loginuid (per strace)
[tye]: disable /proc and then see what it does?
[davido]: then it reads from /etc/passwd to decide who my uid is.
[davido]: sorry, typed that before you asked me to disable proc
[davido]: but you stumped me; don't know how to disable proc.
[tye]: I don't know if you can just dismount, but I thought so.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-06-23 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (554 votes). Check out past polls.