use strict; use warnings; my $word="test"; while() { next if ! /\b($word)\b/; my @arr = split; my $col = ""; my $i=0; foreach my $k (@arr) { $i++; $col .= "$i\t" if $k eq $word; } print "The word repeated in Line $. and in column $col\n"; } __DATA__ This is a test from tester okay nothing message test center test test in proress ... test one test two #### The word repeated in Line 1 and in column 4 The word repeated in Line 3 and in column 2 4 The word repeated in Line 4 and in column 1 5 7