in reply to Getting the right count
#!/usr/bin/perl use Modern::Perl; # 945665 my $count=0; my $num; my @arr = <DATA>; for (@arr) { $num=0; # nul $num to avoid probs from persistenc +e in $1 if ($_ =~ /(\d+)/ ) { # as an alt to splitting on the tab $num = $1; } if ($num > 600) { say "$num > 600ms"; # OP didn't ask for this, but /me # likes visual confirmation in the output $count++; } else { next; } } say "\t count: $count;" __DATA__ 10 alpha 30 bravo 60 charlie 100 delta 500 echo 600 foxtrot 4 golf 22 hotel 900 igloo 800 juliet 999 kilo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting the right count
by mbethke (Hermit) on Dec 31, 2011 at 02:30 UTC | |
by ww (Archbishop) on Dec 31, 2011 at 12:21 UTC | |
by mbethke (Hermit) on Jan 02, 2012 at 18:34 UTC |