Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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";

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 romping around the Monastery: (5)
As of 2016-10-21 22:04 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.