Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Using "my" suppresses "Name used only once" warning?

by jepri (Parson)
on Feb 03, 2003 at 00:32 UTC ( [id://232099]=note: print w/replies, xml ) Need Help??


in reply to Using "my" suppresses "Name used only once" warning?

At first I thought that perl would optimise away useless declarations, but after playing with B::Deparse I discovered that perl did not do this. And then I figured out why:

my $d; my $s = '$d=10;print $d'; eval $s;

Naughty, but still legal. So in this case, it really is a feature, and not a bug.

____________________
Jeremy
I didn't believe in evil until I dated it.

Replies are listed 'Best First'.
Re: Re: Using "my" suppresses "Name used only once" warning?
by PodMaster (Abbot) on Feb 03, 2003 at 08:25 UTC
    Good point.

    I vaguely recall of some discussion for addition of a compile time option to specify that you won't be using eval. The idea may seem appealing, but eval is eval, and s///e is eval, and there are tons of other uses for eval, and lots of modules use eval, that pretty quickly the potential optimization that might be gained by that option (at least for perl5) disappear pretty quickly (that's how I see it).


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.

      s///e is eval
      No, that would be s///ee - the right side of s///e is compiled during the inital compilation phase.

      Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-25 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found