yeah, how about not looping through the file more than once for starters.
#!perl -wl use strict; #bit fields my %status = qw( begin 1 doing-work 2 complete 4 ); # figure out what a "perfect" score is my $ok = (2 ** (scalar keys %status)) - 1; # where we keep stuff my (%entries); #open F, "<logfile" or die $!; while (<DATA>) { if (/^(\d{4}HA-\d{5}) (\S+)$/) { $entries{$1} |= $status{$2}; } } #close F; #filter out entries that passed for (grep{ $entries{$_} == $ok }keys %entries) { delete $entries{$_}; } printf( "%d entries failed\n", scalar keys %entries ); for (sort keys %entries) { print "$_: $entries{$_}"; } __DATA__ 1234HA-00001 begin 1234HA-00002 begin 1234HA-00003 begin 1234HA-00001 doing-work 1234HA-00002 doing-work 1234HA-00001 complete

perl -e'$_="nwdd\x7F^n\x7Flm{{llql0}qs\x14";s/./chr(ord$&^30)/ge;print'


In reply to Re: Efficiently parsing a large file by pizza_milkshake
in thread Efficiently parsing a large file by neilwatson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.