I have a directory full of files containing entries like:
FAKE ORGANIZATION
799 S FAKE AVE
Northern Blempglorff, RI 99xxx
01/26/2011
These items are being held for you at the location shown below each one.
IF YOU ASKED THAT MATERIAL BE MAILED TO YOU, PLEASE DISREGARD THIS NOTICE.
The Waltons. The complete DAXXXX12118198
Pickup at:CHUPACABRA LOCATION 02/02/2011
GRIMLY, WILFORD
29 FAKE LANE
S. BLEMPGLORFF RI 99XXX
I need to delete all records with an expression Pickup at:CHUPACABRA LOCATION.
The problem with the record separator : I can not touch the formatting of the input file - it must be saved as is. Each entry is split into approximately 40+ new lines.
Here are some awk (this works):
BEGIN {
RS="\n\n\n\n\n\n\n\n\n+"
FS="\n"
}
!/CHUPACABRA/{print $0}
My hit with perl:
perl -a -F\n -ne '$/ = "\n\n\n\n\n\n\n\n\n+";$\ = "\n";chomp;$regex="CHUPACABRA";print $_ if $_ !~ m/$regex/i;' data/lib51.000
Nothing returns. I am not sure how to specify a "field separator" in perl, except for the command line. I tried the a2p utility - without cubes. For the curious, here is what it produces:
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z
$, = ' ';
$\ = "\n";
$/ = "\n\n\n\n\n\n\n\n\n+";
$FS = "\n";
while (<>) {
chomp;
if (!/CHUPACABRA/) {
print $_;
}
}
This should work under someone windows window, otherwise I will stick with awk.
Thank!
Buboff
EDIT (SOLVED) **
Thank you crowd! Here's the (working) version of the perl script (a2p output adjusted):
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z
$, = ' ';
$\ = "\n";
$/ = "\n"x10;
$FS = "\n";
while (<>) {
chomp;
if (!/CHUPACABRA/) {
print $_;
}
}
CPAN, / perl-ish. !