in reply to printing up until a certain line within a file

...another method that doesnt need nesting within a sub

How about:

#!/usr/bin/perl -w use strict; open(FH, "/testfile"); while (my $line = <FH>) { last if $line =~ /^## START/; print $line; } close(FH);