Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: when eval corrupts the invoker

by perigeeV (Hermit)
on Jun 25, 2002 at 16:27 UTC ( #177129=note: print w/ replies, xml ) Need Help??


in reply to when eval corrupts the invoker

$0 is Lvaluable so you could anticipate any changes to it. Simplistically you could just:

BEGIN{$0 = "foo"}

Or if you want to watch it's state just tie the thing:

package Progname; use Carp; sub TIESCALAR { my $class = shift; my $newname = shift; return bless \$newname, $class; } sub FETCH { my $self = shift; carp "The program name is being accessed.\n"; return $$self; } sub STORE { my $self = shift; my $attempted = shift; carp "An attempt is being made to change the program name to \"$at +tempted\".\n"; } 1;

And then:

use Progname; tie $0, 'Progname', "NewProgramName";



Comment on Re: when eval corrupts the invoker
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (14)
As of 2014-07-10 21:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (216 votes), past polls