in reply to Parsing a Flat File and counting occurances of numbers?

Hrm, looking at your post history it would seem all your questions so far are somehow related to lines like these. Are you making progress I hope? The following code demonstrates the basic ideas you'll probably employ, but you'll need to make a few changes too I think.

my %range_counts = (); my %counts = (); while( $entire_file =~ m/(\d+)bn(\d+), bytes/sg ) { $range_counts{'4kset'} ++ if $2 > 4000 and $2 < 6000; $counts{$2} ++ if $2 > 4000 and $2 < 6000; } print "there were $counts{'4kset'} 4000-6000 lines\n";

I suspect you'd also benifit from pouring the results into a database of some kind. Then you could run queries like SELECT sum(something_column), avg(something_column) FROM data WHERE something>something and something < something and report on all kinds of interesting details.

-Paul

Replies are listed 'Best First'.
Re^2: Parsing a Flat File and counting occurances of numbers?
by chargrill (Parson) on Dec 22, 2006 at 14:00 UTC

    Hi jettero:

    Indeed, it looks like batcater98 is making progess. To my eye, the output file shown above looks like it could be a straight dump of the output from either my or imp's recent attempts to help batcater98 solve their problem.

    Oh how nice it would've been to have the full spec up front, so that either imp or I could have added this simple addition! Instead, it seems like poor batcater98 has taken one of those referenced programs, run it to produce an output file, and is trying to write another program to produce these (relatively trivial to add) additional results.

    Your simple loop code above would definitely cut the mustard for the spec presented above, but perhaps it would be a Better solution overall to shoehorn something that would fit the spec into the previous solution batcater98 has (apparently without much gratitude) decided to use.

    Update: Just wanted to make it clear that though I was replying to jettero, it was not my intention to berate him, as I feared that the phrase I updated might indicate.



    --chargrill
    s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)
      I do appriciate everyones help in my learning curve toward perl. I am familiar with the language, but do not have the level of deep knowledge that you and others here have. If I am tapping the knowledge base in the wrong fashion, I do appologize. I am attempting to get better and hope to someday be able to return the favors to others in the room as they have helped me out in the begining. Again, Thanks for the help. batcater98