in reply to How do I re-read a line?
#!/usr/bin/perl -w use strict; my @names; my @items; sub processRec { my $fh = shift; #ref to filehandle while(<$fh>) { chomp; s/\cM//; next if /^$/; next if /^\d-RECORD$/; push ( @names, /ITEMNAME-(.*)/); push ( @items, /ITEM \d-(.*)/); } } open( FH, "<data"); processRec(*FH); close(FH); for my $name ( @names ) { print "name = [$name]\n"; } for my $item ( @items ) { print "item = [$item]\n"; }
No sense in using two while loops.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do I re-read a line?
by rbc (Curate) on May 01, 2002 at 22:00 UTC |