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

Re: Re: Re: Caller's Variables

by shotgunefx (Parson)
on Jul 08, 2002 at 20:21 UTC ( [id://180308]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Caller's Variables
in thread Caller's Variables

I could see one or two valid uses. The one place I've used it for production was a tied hash package. We wanted to be able to alias package vars in the hash values with vars from the caller. Retrofitting this to older code was a pain as they HAD to be package variables so we changed the alias sub to look at caller's lexicals and then the package vars.

-Lee

"To be civilized is to deny one's nature."
Update
While on the subject, I should mention a bug/feature of PadWalker. It will NOT see all lexicals visable where the subroutine is called if you have a bare block
#!/usr/bin/perl -w use strict; use PadWalker qw(peek_my); my ($oa,$ob) = ("Outer One", "Outer Two"); { my $inb = "Bare Block"; # Will not be seen by peek_my peeper(); } sub peeper { my $c = peek_my(1); print "Lexicals:\n", (map { "Found $_ with value $c->{$_}\n" } sor +t keys %$c ),"\n"; }


Log In?
Username:
Password:

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

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

    No recent polls found