Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 studying the Monastery: (8)
As of 2014-12-21 17:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls