Well, how about this:
sub print_up_to { my( $handle, $string ) = @_; while( <$handle> ) { last if /$string/o; print; } } use FileHandle; my $fh = FileHandle->new( 'foo' ); print_up_to( $fh, '^## START' ); ## of course, you should be able to do this: open( FOO, 'foo' ); print_up_to( \*FOO, '^## START' );
In reply to Re: printing up until a certain line within a file
by lestrrat
in thread printing up until a certain line within a file
by c
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |