in reply to Re^2: Newbe needs script assistance
in thread Newbe needs script assistance
I think you are trying to do something like show which lines have repeated words in them. The problem description in your original post is a little unclear and seemed to cover several requirements but your code hints at this solution. Given this input file:
this and that fish and chips and mushy peas the cat and catkin boom bang boom
This code:
#!/usr/bin/perl # use strict; use warnings; my $inputFile = q{spw888564.txt}; open my $inputFH, q{<}, $inputFile or die qq{open: < $inputFile: $!\n}; while ( <$inputFH> ) { next unless m{(\w+).*\b\1\b}; print qq{Found '$1' repeated in: $_}; } close $inputFH or die qq{close: < $inputFile: $!\n};
Produces this output:
Found 'and' repeated in: fish and chips and mushy peas Found 'boom' repeated in: boom bang boom
I hope I have guessed correctly and this is some help but please ask more questions if things are unclear.
Cheers,
JohnGG
|
|---|