Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the name of an array

Status
Not open for further replies.

andyros

Programmer
Jul 12, 2005
42
GB
Hi all

This is probably a stupid question with an easy answer...

Is there any way to get the name of an array and use in a string?

say i had the array:

@dogs = ("rover","larry","Bruce");

would it be possible to take the name of the array (dogs) and use it in another variable?

I tried $arrayname = @array but that just gives the num of elements..!

thanks
andy
 
Sounds like trying to use soft references, not a good idea.

Can I ask why you wish to use the name of an array (esp assuming you named it earlier in the code), and why you couldn't perhaps use a numbered hash?

--Paul

cigless ...
 
dog was just an example :)

well ill be feeding data from text files into an array in order to filter the data and write it back out, the name of the array will be the name of the text file which will be used to create directories.

I've just realised that i can use the text file name and not the array name, my apologies...I'm not awake yet!!

andy
 
Paul isn't having a dig at you because you chose the word dog - he is trying to point at that if you let the script dictate the variable names - i.e. soft references - that you are no longer in control of what they might end up being set to. You could end up using a reserved name... for example - and that aint good!


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top