rayv has asked for the wisdom of the Perl Monks concerning the following question:
I am parsing a rather large input file using the follow-
ing perl code:
while (my $line = <$fh>) { chomp($line); my ($uid, $login, $cpupr, $cpunpr, @data) = (split("\t",$line)); }
I want to stop parsing lines when a certain string is
found in the input file. Would anyone be able to
assist me in accomplishing this? I am able to use a
pattern match to determine when this string is found,
but I am not sure how to get perl to stop parsing lines
of input at this point. The pattern matching regular
expression is:
if ($line =~ /TOTAL COMMAND SUMMARY/)
I am putting this after 'split' line and before the
while loop ends.
I hope someone can tell me what to do in the block
associated with this if statement or maybe this should
be some other kind of control loop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Terminating Read Of Input
by moritz (Cardinal) on Aug 14, 2007 at 13:33 UTC | |
by tirwhan (Abbot) on Aug 14, 2007 at 13:50 UTC | |
by SuicideJunkie (Vicar) on Aug 14, 2007 at 14:56 UTC | |
|
Re: Terminating Read Of Input
by perlofwisdom (Pilgrim) on Aug 14, 2007 at 17:45 UTC |