in reply to Re: Delete all "records" which contain a regex match
in thread Delete all "records" which contain a regex match

My apologies. Here are two methods that I have tried that read in a file from stdin:

Attempt 1:
#!/usr/bin/perl -w undef $/; while (<>) { s/^COMMENT:\s+AUTHOR: .*?poker.*?^-----$//gsm; print; }
Attempt 2 (completely nonsensical):
#!/usr/bin/perl -w #undef $/; while (<>) { next unless (@foo = /^COMMENT:$/ ... /^-----$/); print if ! /poker/; # $_ =~ /poker/; # print $_, "\n"; print @foo; }
Buddha bless you.

Replies are listed 'Best First'.
Re^3: Delete all "records" which contain a regex match
by prasadbabu (Prior) on Jun 05, 2006 at 16:04 UTC

    Hi, ilovechristy, here is one way to do it. Also have a look at perlre.

    use strict; use warnings; local $/; my $data = <DATA>; $data =~ s/COMMENT:(?:(?!-----).)*-----//gs; print $data; output: ------- AUTHOR: bobMonk TITLE: Monk Software Chart STATUS: Publish CATEGORY: Monks DATE: 05/21/2006 11:36:16 AM -----

    Prasad