i'm working on printing the content of a file, but only up until a certain point. in my case, its until a line beginning with ## START shows up. my code
#!/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