in reply to hash values

$ cat infile1.txt line1 line3 line2 line1 line3 line4 line2
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; my $myfile = '/dir/subdir/infile1.txt'; open( my $in, '<', $myfile) or die "Can't open $myfile: $!"; map { chomp; $hash{ $_ }++ } <IN>; close($in); print Dumper \%hash;
Output: $VAR1 = { 'line3' => 2, 'line2' => 2, 'line4' => 1, 'line1' => 2 };

hth,

PooLpi

Update : chomp