in reply to printing up until a certain line within a file
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' );
|
|---|