Ben328 has asked for the wisdom of the Perl Monks concerning the following question:
I have lines as follows in a file
Today is amazing.nice day Today is amazing.nice but still I haven't done anything Yesterday was just a normal day Tomorrow probably will be amazing.new day
What i want to accomplish : I want to be able to go through lines and match "(amazing.*)". If (amazing.*) is unique then put it in an array and also print that line if not ignore it. Basically, this is the result I am looking for.
and so forth....Today is amazing.nice day Tomorrow probably will be amazing.new day
So far I have only written this much code. I just don't know where to go from here. Any direction on how to approach this would be very much appreciated.
#!/usr/bin/perl -w use strict; while ( my $line = <> ) { if ( $line =~ m/(\(amazing.+?\))/) { my $string="$1"; @allstrings = ($string); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to ignore lines that match certain string after it is matched for the first time within a same file
by Kenosis (Priest) on Sep 19, 2012 at 23:47 UTC | |
|
Re: How to ignore lines that match certain string after it is matched for the first time within a same file
by ikegami (Patriarch) on Sep 19, 2012 at 23:09 UTC |