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.
|