Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Get the $main value when use local

by blazar (Canon)
on Aug 04, 2005 at 09:11 UTC ( [id://480730]=note: print w/replies, xml ) Need Help??


in reply to Get the $main value when use local

AFAIK, you can't. That's the whole point about local. Any good reason why you need to use local instead of my? You may try giving a peek into Coping with Scoping and Seven Useful Uses of local for insightful info.

As a side note, read perldoc perlvar to find out why as a general rule $a should not be used as a general purpose variable.

Update: all in all your test code may have been written like thus:

#!/usr/bin/perl -l $c='main'; { local $c='sub'; print $c; print $main::c; } print $c; __END__

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-29 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found