in reply to Re^15: quickness is not so obvious
in thread quickness is not so obvious
How about something simple?
use autodie; while (<>) { last if /^__END__/; next if /^\s*#/; ...; }
Now, the same functionality implemented with the guidelines.
(Since this is Perl, I am adapting the guidelines to encompass Perl concepts.)
my $EndOfInput = 0; for my $file (@ARGV) { if (0 == $EndOfInput) { if (open(my $fh, '<', $file)) { while (my $line = <$fh>) { if (0 == $EndOfInput) { if ($line =~ /^__END__/) { $EndOfInput = 1; } else { if ($line !~ /^\s*#/) { ...; } } } } } else { die "Can't open $file: $!"; # we are allowed to die on fat +al errors } } }
|
|---|