Balls McWang has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to create an array name from a line of information I've found in another array. Then I would like to be able to push data into that array and print it out to a file later on.
What I think I need to do is use a reference ... but I don't think I'm doing it correctly and I'm getting lost Programming Perl: Chapter 8. I use references in Tk and other modules but I've always just learned by example
Realise I'm way off here and would appreciate help even if it's just to a page in the book or a node I should read.
Here's what I'm doing ... part of a bigger file.
Thanks,
James
scalar(@dev_list) == $#dev_list + 1; scalar(@xref) == $#xref + 1; for ($i=0; $i < (scalar(@dev_list)); $i++) { print STDOUT "Looking for $dev_list[$i]\n"; for ($c=0;$c < (scalar(@xref)); $c++) { if($xref[$c] =~ /$dev_list[$i]\./i) { $templine = join "_","\@dev_xref",$dev_list[$i]; $dev_array_ref = \($templine); push(\$dev_array_ref, $xref[$c]); } } }
Edit: Corrected the <code> tag. larsen
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: creating an array name using information from another array
by waswas-fng (Curate) on Mar 04, 2004 at 19:36 UTC | |
|
Re: creating an array name using information from another array
by maa (Pilgrim) on Mar 04, 2004 at 19:19 UTC | |
|
Re: creating an array name using information from another array
by NetWallah (Canon) on Mar 04, 2004 at 19:22 UTC | |
|
Re: creating an array name using information from another array
by graff (Chancellor) on Mar 05, 2004 at 04:28 UTC | |
by Balls McWang (Novice) on Mar 05, 2004 at 15:02 UTC |