Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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,

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2015-11-30 12:34 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (770 votes), past polls