in reply to Match a string only once in a file
my @array = ('file', 'this', 'dog', 'forward' ); my $searchstring = join '|',@array; foreach ( @file ) { if ( /($searchstring)/i ) { push @stringsfound,$1 unless grep { $_ eq $1 } @stringsfound; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Match a string only once in a file
by Roy Johnson (Monsignor) on Mar 08, 2005 at 01:19 UTC | |
by hsinclai (Deacon) on Mar 08, 2005 at 04:18 UTC |