Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: creating an array name using information from another array

by maa (Pilgrim)
on Mar 04, 2004 at 19:19 UTC ( [id://333983]=note: print w/replies, xml ) Need Help??


in reply to creating an array name using information from another array

Hi,

I'm not sure what the point of the lines scalar(@dev_list) == $#dev_list + 1; scalar(@xref) == $#xref + 1; is since == is an equality test - are these lines supposed to be comments for you?

A more perlish way to write your nested for loops would be:

for my $devitem (@dev_list) { print "Looking for $devitem\n"; for my $xrefitem (@xref) { if ($xrefitem =~ /$devitem/i) { #Do you really need to match a +nother character? #What's the next line for? # $templine=join "_","\@dev_xref",$dev_list[$i]; my @{$templine}[0]=$xrefitem; } }

I'm not entirely sure that I understood what you were trying to do but you can create variables named using the contrents of another variable using the ${$varname} style syntax. But then you have to store your created variable's name so you can access it later... it might be easier to pre-dclare a hash and use the keys function.

HTH - Mark

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-26 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found