c has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -wT use strict; open(FH, "/testfile"); my @lines = <FH>; &test; close(FH); sub test{ for my $i(@lines) { if ($i =~ /^\#\# START/) { return; } else { print $i; } } }
this works, but it uses return and needs to be held within a subroutine to work. it seems like there should be a better way to do this, and i just am not crafty enough to come up with it. can someone point out another method that doesnt need nesting within a sub?
humbly -c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Or from the command line line . . .
by Fletch (Bishop) on Oct 25, 2001 at 03:30 UTC | |
|
Re: printing up until a certain line within a file
by dvergin (Monsignor) on Oct 25, 2001 at 02:43 UTC | |
|
Re: printing up until a certain line within a file
by lestrrat (Deacon) on Oct 25, 2001 at 02:31 UTC | |
|
Re: printing up until a certain line within a file
by blackmateria (Chaplain) on Oct 25, 2001 at 02:52 UTC | |
|
Re: printing up until a certain line within a file
by Rex(Wrecks) (Curate) on Oct 25, 2001 at 04:43 UTC |