Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^16: quickness is not so obvious

by RonW (Parson)
on Jan 30, 2015 at 00:36 UTC ( [id://1115008]=note: print w/replies, xml ) Need Help??


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 } } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1115008]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-20 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found