Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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 contemplating the Monastery: (7)
As of 2015-12-01 04:54 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (794 votes), past polls