Jul 6, 2013, 1:51 PM
If I may first comment on your code:
Re: [AndrewF] Need help printing out only certain items in a file
There are a number of things that are good practice using Perl.
1. You should use 3 - argument of open function in Perl,
2. Use a lexical scope file handles,
3. Check the return of the both "open" and "close" function or you use "autodie".
All of that is demonstrated below:
open my $fh,' <', 'practice.txt' or die "can't open file: $!";
close $fh or die "can't close file: $!";
That been said, this is one way of going what you wanted:
After opening the file, you could step through the file a line at a time, split on "/" and get the value you wanted.
Make an ARRAY of ARRAY and store this values.
Then you can print out all the values you want.
Please let me give you a head up with a little code that does what I think you want.
<DATA>; #remove the heading if not needed
$counter = 0;
print Dumper \@data;
print join $/=> map @$_ => @data;
Johnson & Johnson|JNJ|US|5
$VAR1 = [
For ARRAY of ARRAY, please read up http://perldoc.perl.org/perldsc.html#ARRAYS-OF-ARRAYS
(This post was edited by 2teez on Jul 6, 2013, 2:07 PM)