in reply to printing up until a certain line within a file
How about:
#!/usr/bin/perl -w use strict; open(FH, "/testfile"); while (my $line = <FH>) { last if $line =~ /^## START/; print $line; } close(FH); [download]