Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re (tilly) 1: Oh Brother.

by satchboost (Scribe)
on Apr 12, 2001 at 22:27 UTC ( #72133=note: print w/replies, xml ) Need Help??


in reply to Re (tilly) 1: Oh Brother.
in thread My Laptop talks to me.

I have to comment. Using symbolic references of the form $$i is stupid. It's more than stupid. You're creating unknown global variables in your script. If you're a dealing with user input, you should be socked. (Homey don't play dat!)

However, if you use symbolic references of the form ${"$package_name::$i"}, I think you're quite a bit safer. You have made sure that the global namespace is safe, especially as you're in control of $package_name. Why would you do this? Well, there's a way of implementing objects using parallel arrays instead of hashes. In certain cases, where you have a large number of instances of this class and/or you will be creating/destroying them on a regular basis, it's much faster, even with the cost of string interpolations and symbolic references.

To sum up, I don't think symbolic references are necessarily a "Bad Thing"(tm). I would actually say it's that global things are almost always bad and that the default way of creating a symbolic reference is in the global namespace.

Replies are listed 'Best First'.
Re (tilly) 3: Oh Brother.
by tilly (Archbishop) on Apr 12, 2001 at 22:35 UTC
    If you look through my examples you will find symbolic references being used as well. Turning around a recent discussion between us, this is the same issue as using AUTOLOAD all over. Using it immediately opens you up to all sorts of confusions and possible kinds of grief. But with it you can effectively write a program that writes your code for you - which can accomplish very powerful things. Therefore use it, with caution, wisely, but only where it makes sense.

    In other words all rules are there because most of the time they make your life easier. But they have exceptions, and when you arrive at a legitimate exception, you should not fear unnecessarily to break the rule. However if you find yourself often deciding that the rule is to be broken, then you are probably doing something seriously wrong and you are probably mistaken. (Because, after all, most of time the rule is right!)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2022-05-21 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?