I am reading a text file named, mention-freq, which has data in the following format:
1
1
13
2
I want to read the lines and store the values in an array like this: @a=(1, 1, 13, 2). The Perl push function gives the index values/line numbers, i.e., 1,2,3,4, instead of my desired output. Could you please point out the error? Here is what I have done:
use strict;
use warnings;
open(FH, "<mention-freq") || die "$!";
my @a;
my $line;
while ($line = <FH>)
{
$line =~ s/\n//;
push @a, $line;
print @a."\n";
}
close FH;
twoHandsTwoCutsFunctionfunction :)sub{map{s/^\s+//; s/\s+$//; $_}@_}