I have a test file that looks like this:
TAXFN
A GREAT BIG
TITLE
PAGE: 1
A SMALL
TITLE
RUN DATE: 05/01/01
SUBTITLE
I read down into the file until I find a match on "A SMALL
TITLE". I then call a subroutine to further process the file.
I am looking for the report id which is TAXFN and the run date.
This code works:
seek(FILE,0,0);
# Back to the beginning of file
$reread = <FILE>; chomp($reread); print "$reread\n"; $reread =~ /(\s*\w+)/; $REPID = $1; $REPID =~ s/^\s+//; $REPID =~ s/\s+$//; print "Report ID = $REPID\n"; <FILE>; chomp; /(\d{2})\D(\d{2})\D(\d{2})/; print "Run Date = $1\/$2\/$3\n"; while this code doesn't:
seek(FILE,0,0);
# Back to the beginning of file
<FILE>; /(\s*\w+)/; $REPID = $1; $REPID =~ s/^\s+//; $REPID =~ s/\s+$//; print "Report ID = $REPID\n"; <FILE>; chomp; /(\d{2})\D(\d{2})\D(\d{2})/; print "Run Date = $1\/$2\/$3\n"; In the doesn't work code I always end up with the second line. Why does
reading into a variable instead of $_ make a difference?
Why does the read for the date work with $_ just fine?? I am
confused.
TIA for any thoughts.
--
------------------------------------------------------------------------- "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- Benjamin Franklin
------------------------------------------------------------------------- RRRRR Gary Luther RR RR SAF RR RR UTABEGAS 2500 Broadway RR RR Helena, MT 59602 RRRR [EMAIL PROTECTED] RR RR ULE !! RR RR Visit our website at RR RR http://www.safmt.org |
BEGIN:VCARD VERSION:2.1 X-GWTYPE:USER FN:Gary Luther TEL;WORK:0631 ORG:;Computer Center TEL;PREF;FAX:(406) 444-0684 EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED] N:Luther;Gary TITLE:Systems Administrator END:VCARD