Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: Make $^V and "my" implicit

by Corion (Patriarch)
on Feb 03, 2014 at 17:52 UTC ( [id://1073241]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Make $^V and "my" implicit
in thread Make $^V and "my" implicit

But if that case is not-so-common, then you don't need my at all.

my forces you to predeclare variables. This is highly important, as Perl can then tell you if you misspell a variable.

It has the additional advantage of allowing you to explicitly declare the scope of a variable, to tell Perl whether you meant to create a new, lexically scoped variable or whether you meant to use the global variable.

I think most of your complaints can be done away with by not using strict. Then you don't need to predeclare your variables but still can use lexical variables with my. Of course, recursion is a harsh mistress if you're using global variables. Typos also are a nasty problem. But you don't seem to have these.

Replies are listed 'Best First'.
Re^4: Make $^V and "my" implicit
by gunzip (Pilgrim) on Feb 03, 2014 at 18:02 UTC
    I'm aware you do need a way of distinguishing variables of the same type and name used in different scopes but "my" just seems to over-generalise the issue to the point that it becomes boilerplate. Depends on your view at the end of the day, I suppose.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-24 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found