Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Thanksmy $word="test"; while(<DATA>) { if(/\b($word)\b/) { @arr = split(/\s+/,$_); $col = ""; $i=0; foreach $k (@arr) { if($k eq "$word") { $col.=($i+1)."\t"; } $i++; } 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can anyone simplify this code
by GrandFather (Saint) on Jan 11, 2007 at 09:18 UTC | |
by Anonymous Monk on Jan 11, 2007 at 12:28 UTC | |
|
Re: Can anyone simplify this code
by johngg (Canon) on Jan 11, 2007 at 10:40 UTC | |
by Anonymous Monk on Jan 11, 2007 at 12:35 UTC | |
|
Re: Can anyone simplify this code
by ambrus (Abbot) on Jan 11, 2007 at 11:45 UTC | |
by Anonymous Monk on Jan 11, 2007 at 12:36 UTC | |
|
Re: Can anyone simplify this code
by shmem (Chancellor) on Jan 11, 2007 at 10:38 UTC | |
by Anonymous Monk on Jan 11, 2007 at 12:32 UTC | |
|
Re: Can anyone simplify this code
by Samy_rio (Vicar) on Jan 11, 2007 at 10:05 UTC | |
by Anonymous Monk on Jan 11, 2007 at 12:27 UTC |