Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Variable scalar creation.

by davido (Cardinal)
on Feb 13, 2005 at 05:56 UTC ( [id://430532]=note: print w/replies, xml ) Need Help??


in reply to Variable scalar creation.

Forgetting about symbolic references ( variables dynamically named ) and forgetting the above snippet, could you please explain what exactly you're trying to accomplish? It almost looks like you're trying to associate a bunch of field names with a bunch of values, and maybe trying to create variables named after those fieldnames, though the code above isn't quite doing that. With a little more explanation and clarification someone's going to come along and help you find the proper way to accomplish what you really need, instead of what you're currently asking for.

If you want to just create a bunch of variables named after the contents of @names, you would probably do it this way:

no strict qw/refs/; @::{@names} = \( @values );

But that's a surefire way to cause yourself all sorts of headaches that you really don't want to suffer through. You know, the global symbol table, that you're trying to muck around with, is just a glorified hash. If it's good enough for Perl, it's probably good enough for you too: use a hash.

UpdatedUsed a symbol-table slice instead of original foreach loop, just for fun and reckless disregard for the safety of mankind.


Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-03-29 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found