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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Array

Status
Not open for further replies.

dgallig

Technical User
Jan 1, 2008
3
IT
Hello everybody ,
I have a problem with arrays ...
I need to get some data from files in some directories .

The names of the dirs are something like 12.12344 or 23.34441.
Some contains one , some 2 or 3 files .

I'd like to get data from those dirs recursively ... but dunno how .

I've tried something like :

@DIR=("12.12344","23.34441");
@12.12344=("height","width");
@23.34441=("height");

and then reading with 2 nested foreach :

foreach $directory (@DIR) {
foreach $element ($[@directory]){ <- this is wrong I know , but how can i do something like this ??

1) I can't use the "." in the name of the array
2) Dunno how to use the variable name as the name of the array ...


I tried even with something like :

%DIR=("12.12344","height",
"23.34441","height",
"12.12344","width")

and using :
while (($directory, $element) = each(%DIR)){

but isn't working either , seems because the keys are repeated .

Maybe it's a stupid problem , I know , but this is my first
try in Perl :) ( Yes , I' m a total noob :) )

Someone can help ?

Thx in advance

David


 
Thx travs69
but i have this problem ...
Those dirs all contains a lot of files and subdirs ,
and when not needed some files in the dirs have "fakes" values
i don't want t read .
Example :
dir 12.6567 has a "height" file which contains a value i want
to read and a "width" file which contains a value that is normal in all respects but is fake , and I'm not interested in reading it ...
Dunno if I have explained it well , or now is worst than before ...
 
how can you tell that the width value is a fake?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Because could be far too big or far too low ... but something
in the middle and reasonable too sometimes ... It's completely random . So can trick the scripts ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top