On Wed, 02 Feb 2005 01:49:31 -0800,
wrote:
> having all sorts of problems extracting the data. The file I am
> extracting on is library catalog records. For instance sometimes I get
> the subject printing in the wrong record, or blank lines between each
> subject (some records have more than one subject field)
It looks to me like you aren't removing the newline from the end of your
input lines. See extra line in code below.
<SNIP>
> my $title;
> my $author;
> my $call;
> my $subj;
>
> for my $line (@lines)
> {
chomp($line); # <-- Will remove newline from end of $line, if present
> $line =~ /TITLE/ and $title = $line;
> $line =~ /AUTHOR/ and $author = $line; $line =~ /CALL/ and $call =
> $line;
> $line =~ /SUBJ/ and $subj = $line;
> #$line =~ /did not find/ and print $title,$line,"\n"; $line =~ /PUB/ and
> print $title,$author,$call,$subj,$line,"\n";
>
> }