Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: regexp exclude a string

by murugu (Curate)
on Jan 19, 2006 at 14:18 UTC ( #524226=note: print w/ replies, xml ) Need Help??


in reply to regexp exclude a string

Hi Murcia,

If i understand your question correctly, Here is my code.

#get the files under a directory using readdir or glob. my @a = qw(text1 text2 text3);# filenames in an array. my @found; foreach my $a (@a) { my $FH; open ($FH, $a) or die ("unable to open $a: $!\n"); while (<$FH>) { if (m/green|blue|red/ && !m/green red blue/) { push @found ,$a; last; } } close $FH; } print $_,$/ for (@found);

Regards,
Murugesan Kandasamy
use perl for(;;);


Comment on Re: regexp exclude a string
Download Code
Replies are listed 'Best First'.
Re^2: regexp exclude a string
by blazar (Canon) on Jan 19, 2006 at 15:00 UTC

    And if I understand his question correctly, this will fail if he has "this is green and yellow" on one line in a file and "green red blue" on the next one.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://524226]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (14)
As of 2015-07-31 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls