Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: storing variable names in an array

by kirbyk (Friar)
on Jun 10, 2005 at 20:10 UTC ( #465669=note: print w/ replies, xml ) Need Help??


in reply to storing variable names in an array

It's possible to do that, but it's not really the easiest way.

Consider using a hash instead:

my %files = ( 'file1' => 'tom', 'file2' => 'bob', 'file3' => 'joe', ); $files{'file2'} = 'sam';
Alternately, just store your filenames in the array (if order is important), like:
my @names = ('tom','bob','joe'); $names[1] = 'sam';
Adding the additional step of the array of variable names is usally the wrong path to go down.

-- Kirby, WhitePages.com


Comment on Re: storing variable names in an array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (15)
As of 2014-10-23 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls