in reply to How do I re-read a line?

Hmm, how about something like this instead?
#!/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.


Matthew Musgrove
Who says that programmers can't work in the Marketing Department?
Or is that who says that Marketing people can't program?

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
    Thanks Mr. Muskrat,

    Your solution works. But what if I was only able to
    edit the sub processRec?

    I am sorry for not stating that in my original post and
    thanks for your reply! :)