dukea2006 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I'm struggling with something that I think is pretty simple, but I haven't been able to work it out and I'm hoping you all can lend a hand.
I have a Tab Delimited file similar to the following:
What I need to be able to do is count those values in the first column that meet certain criteria such as >600,>1000, etc. So, using the data above, if I wanted to count those values that are > 600, I want a total result of "3".10 alpha 30 bravo 60 charlie 100 delta 500 echo 600 foxtrot 4 golf 22 hotel 900 igloo 800 juliet 999 kilo
#!/usr/bin/perl use warnings; use strict; #open and read, the file my $file = shift @ARGV; open (FILE1, "<", $file) or die "Can't open '$file': $!"; while (<FILE1>) { chomp $_; my($perfNum,$alphaVal) = split("\t", $_); #print "$perfNum\n"; my$gt600ms=0; if($perfNum > 600) { $gt600ms++; print "$gt600ms\n"; } } close (FILE1);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting the right count
by flexvault (Monsignor) on Dec 30, 2011 at 20:22 UTC | |
by dukea2006 (Novice) on Dec 30, 2011 at 21:51 UTC | |
|
Re: Getting the right count
by ww (Archbishop) on Dec 30, 2011 at 20:57 UTC | |
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 | |
|
Re: Getting the right count
by Marshall (Canon) on Dec 30, 2011 at 21:26 UTC | |
|
Re: Getting the right count
by JavaFan (Canon) on Dec 31, 2011 at 03:23 UTC | |
|
Re: Getting the right count
by TJPride (Pilgrim) on Dec 31, 2011 at 02:13 UTC |