On Monday, April 8, 2002, at 05:10 PM, Bryan R Harris wrote:
> open (FILE, $file) || die("Couldn't open $file: $!\n"); > @_ = <FILE>; > close(FILE); > while ($_[1] =~ /^[#\n]/) { push(@comments, shift(@_)); } > print "@comments"; seems unnecessary to create an array then print each element. just print each line as you go. also this loop will stop when you get to first '#' or '\n'. that isn't what you want, right? i would also suggest not using '@_' as an array name. it has a special meaning in a subroutine. so maybe: open (FILE, $file) || die("Couldn't open $file: $!\n"); while (<FILE>) { # don't print lines that start with '#' or are all blanks. print $_ if !/^#/ and !/^\s*$/; }