Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2015-10-09 08:53 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (236 votes), past polls