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

Re^3: The default hash - accident, coincidence or conspiracy?

by tlm (Prior)
on Jul 02, 2005 at 18:32 UTC ( [id://471950]=note: print w/replies, xml ) Need Help??


in reply to Re^2: The default hash - accident, coincidence or conspiracy?
in thread The default hash - accident, coincidence or conspiracy?

I don't understand why people think it's asking for trouble.

IMO, using package variables in one's code, in general, is asking for trouble (though there may be situations in which one is willing to accept this trouble). Moreover, as I pointed out, some module authors have had the bright idea of using variables such as %_, so one can't be sure that these variables are completely available, and that the other code that uses it is being good about using local whenever it uses the same variables. IMO, having to even worry about these things falls into the category of "trouble." The fact that the docs specifically state that the variables the OP asked about are reserved for Perl's use makes it all the more troublesome to use them.

the lowliest monk

Replies are listed 'Best First'.
Re^4: The default hash - accident, coincidence or conspiracy?
by jdporter (Chancellor) on Jul 02, 2005 at 22:39 UTC

    Sure, and some module authors have had the bright idea of using $_. If you use a module that uses $_ (or any other global) and they haven't properly localized, then maybe you should rethink using that module. For better or worse, that's the way it is in the perl world. It's true for $_, and it's just as true for %_.

    You know, just because a module is out there doesn't mean people should use it. Would you use a module that didn't use strict and made all its variables global in %main:: ? I sure wouldn't.

      The $_ example is misleading, because Perl provides a lot of extra built-in help (like implicit localization) that it doesn't provide for other such variables. (I can easily imagine perfectly well-behaved modules that make heavy use of $_ without ever using a single explicit localization of $_.) Without this extra help I think the use of $_, at least in modules, would become much less attractive. An even with all the extra help, the use of $_ is still fraught with trouble.

      the lowliest monk

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-19 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found