Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: print log file

by fenLisesi (Priest)
on Nov 30, 2006 at 07:00 UTC ( #586884=note: print w/replies, xml ) Need Help??


in reply to print log file

use strict; use warnings; my $THRESHOLD = 2.5; LOG_ENTRY: while (my $line = <DATA>) { if ($line =~ /^(\d+)/) { my $stamp = $1; if ($stamp > $THRESHOLD) { process_line( $line ); last LOG_ENTRY; } } else { warn "Bad line: $line"; } } while (my $line = <DATA>) { process_line( $line ); } exit(0); sub process_line { print $_[0]; } __DATA__ 1 llama 2 alpaca 3 camel 4 badger

prints:

3 camel 4 badger

HTH.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2021-10-17 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (71 votes). Check out past polls.

    Notices?