Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

RE: Re: YAlQ: Yet Another local() Question.

by BlaisePascal (Monk)
on Aug 04, 2000 at 00:30 UTC ( [id://26088]=note: print w/replies, xml ) Need Help??


in reply to Re: YAlQ: Yet Another local() Question.
in thread YAlQ: Yet Another local() Question.

Ah, that would also explain why there is the IMHO arbitrary restriction that you can only localize global variables, and not lexical ones. Why something like:
{ my $fh; sub init_print_log { $fh = shift;} sub print_log { print $fh scalar localtime,@_;} sub print_log_altfile { local $fh = shift; print_log(@_);} }
is illegal, even though the -concept-, if not that particular example, is useful.

UPDATE: Yes, save() would be a better name... better than some of the others that have been suggested. Someone also suggested renaming my() to local(). I hope that one doesn't fly.

Replies are listed 'Best First'.
My vs. YAlQ: Yet Another local() Question.
by chip (Curate) on Aug 04, 2000 at 06:38 UTC
    Actually, I have a patch that makes local() work on lexical variables. Larry didn't want to use it because he thought people would be too confused. :-(

    And I wouldn't worry about my() being renamed to local(). Larry chose the word "my" at least in part because it's short and easy to read and write.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-03-28 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found