Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Make $^V and "my" implicit

by dsheroh (Prior)
on Feb 04, 2014 at 09:30 UTC ( #1073354=note: print w/replies, xml ) Need Help??

in reply to Make $^V and "my" implicit

If we've admonished for so many years to (almost) always use "my" variables for proper scoping surely it is now time to makey "my" implicit?
Time to implicitly require my? Sure. That's already been done. If you request the current Perl standards, it turns on strict, too.

Time to make my itself implicit? Nope. It's not time now and it never will be. The fact that you ask the question at all suggests to me that you have greatly misunderstood the purpose (and benefits) of my.

use strict; my $width = 800; if ($height == 768) { $with = 1024; }
This blows up, as it should, because I misspelled $width as $with. If we remove my by somehow "making it implicit", then how is Perl to know that $with is a typo rather than a new variable? That's not a "special case", it's a core benefit of strict.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1073354]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2018-02-24 03:12 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.