Violet has asked for the wisdom of the Perl Monks concerning the following question:
I am completely new to Perl and would like some feedback/assistance. Hoping I don't make anyone cringe too badly.
Trying to open a list and use each item on the list to bring out information on that item from the open file. Items will be listed in the second column of the file, but if the item matches I need to print all columns for that file.
When I list all the items out directly in my code instead of opening the list, the code works. However, when I add the element of opening the list, I get no readout whatsoever.
There are no warnings, so I can't figure out what's wrong. The format of my list maybe?
#! C:\Perl\bin\perl -w open (LIST, "List.txt" ); @mylist = (<LIST>); open (FILE, "FILE.txt" ); @myfile = (<FILE>); foreach $file(@myfile) { foreach $list(@mylist) { @temp = split (/\t/, $file); chomp @temp; if ( $temp[1] eq $list ) {print ("$file")} } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looping in a Loop
by Athanasius (Archbishop) on Sep 16, 2014 at 13:24 UTC | |
|
Re: Looping in a Loop
by toolic (Bishop) on Sep 16, 2014 at 12:53 UTC | |
|
Re: Looping in a Loop
by LanX (Saint) on Sep 16, 2014 at 12:57 UTC | |
|
Re: Looping in a Loop
by johngg (Canon) on Sep 16, 2014 at 14:08 UTC | |
|
Re: Looping in a Loop
by VinsWorldcom (Prior) on Sep 16, 2014 at 13:39 UTC |