#!perl =head2 NAME Find regex in field extract =head2 Use as template for finding a regular expression in individual fields. Input file should be result (export file) from fieldextraction.pl or similar file. Output file is list of lines matching the desired regular expression. =cut print "Input file: "; $inputfile = <>; chomp $inputfile; $inputfile =~ s/^\"(.*)\"$/$1/; print "Export file: "; $exportfile = <>; chomp $exportfile; $exportfile =~ s/^\"(.*)\"$/$1/; open (IN, "<$inputfile") || die ("can't open in"); open (OUT, ">$exportfile") || die ("can't open out"); #if using MacPerl, set creator and type to BBEdit and Text if ($^O eq 'MacOS') { MacPerl::SetFileInfo('R*ch', 'TEXT', $exportfile); } my $linecount = 0; while (my $line = ) { chomp $line; #remove extra spaces between tabs $line =~ s/\t\s{7}\@/\t\@/g; #remove count, tag, and first subfield code $line =~ s/^\d+?\t\d{3}\s[ \d][ \d]\s\@\w\t//; #change to 'if' for opposite #change text between // for desired regex unless ($line =~ /\t/) { print OUT "$line\n"; $linecount++; } } close IN; close OUT; print "$linecount lines identified\n"; print "Press Enter to quit"; <>; =head1 LICENSE This code may be distributed under the same terms as Perl itself. Please note that this code is not a product of or supported by the employers of the various contributors to the code. =head1 AUTHOR Bryan Baldus eija [at] inwave [dot] com Copyright (c) 2003-2004 =cut