in reply to unreadline function?
You said in your question that "special tag starts record off".
That's your answer. Right now you're reading in line by line, but you should instead, read the file in record by record. That's pretty easy to do if the special tag is in some way uniform. Let's say the special tag is "<RECORD>". Set the input record separator to that instead of newline, and then read records in their entirety. At that point, if you still need to further split things down using newlines as delimeters, you can split on newline at that point. Here's how:
{ local $/ = "<RECORD>"; open INFILE, "<in.dat" or die "Bleah!\n$!"; while ( my $record = <INFILE> ) { chomp $record; # strip off the record separator. my @rec_lines = split /\n/, $record; # process each record line here. } close INFILE; }
I hope this helps!
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: unreadline function?
by aquarium (Curate) on Mar 01, 2004 at 04:38 UTC | |
by esskar (Deacon) on Mar 01, 2004 at 04:49 UTC | |
by aquarium (Curate) on Mar 01, 2004 at 04:43 UTC | |
|
Re: Re: unreadline function?
by esskar (Deacon) on Mar 01, 2004 at 03:46 UTC |