in reply to Re: unreadline function?
in thread unreadline function?

thank you all for your responses....i've fashioned some code as follows into a separate script that runs as the first script in a pipeline, e.g. perl pre_script <bibfile | perl processing_script. this nicely separates the complex/multipath processing away from the multiline problem. I know i could have been more concise...but this problem was all about converting the data to get a job done; not to make pretty code. Thanks once again....+es all round.
while($line=<>) { chomp $line; if($line=~/^\*\*\* DOCUMENT BOUNDARY \*\*\*/) { check(); print "$line\n"; next; } if($line=~/^FORM=/) { check(); print "$line\n"; next; } if($line=~/\.\d\d\d\./) { check(); $started_tag = 1; } $tag.=$line; } sub check() { if($started_tag) { print "$tag\n"; undef $tag; $started_tag = 0; } }

Replies are listed 'Best First'.
Re: Re: Re: unreadline function?
by esskar (Deacon) on Mar 01, 2004 at 04:49 UTC
    it could be faster if you do
    if((index($line, "*** DOCUMENT BOUNDARY ***") == 0) or (index($line, "FORM=") == 0)) { check(); print "$line\n"; next; } elsif($line=~/\.\d{3}./) { # ...
Re: Re: Re: unreadline function?
by aquarium (Curate) on Mar 01, 2004 at 04:43 UTC
    oh...almost forgot....did find a IO-Unread module on CPAN...but version is 0.06