Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: bootlog.txt shrinker

by a (Friar)
on Mar 09, 2001 at 10:25 UTC ( #63185=note: print w/ replies, xml ) Need Help??


in reply to bootlog.txt shrinker

Nice. Always wondered what was important in that file, however a couple of things: seems like you're doing more work than needed (why the "not eof( ..." as opposed to

while ($readline = <BOOTLOG>)
but then I ended up needing the $readline to get your exact output.) and going through the entire @aok each line is slower. I thought a snazzy RE would help, but I ended up w/:
#!/usr/bin/perl -w use strict; my ($readline,$found); my %aok=("Loading Vxd" => 1, # A list of all the different + values "LoadSuccess" => 1, # that should be ignored. Oth +ers are "Loading Device" => 1, # left in for debugging purpo +ses. "LoadSuccess" => 1, "SYSCRITINIT" => 1, "SYSCRITINITSUCCESS" => 1, "DEVICEINIT" => 1, "DEVICEINITSUCCESS" => 1, "Dynamic init device " => 1, "Dynamic init success" => 1, "Dynamic load device " => 1, "Dynamic load success" => 1, "Initing" => 1, "Init Success" => 1, "INITCOMPLETE" => 1, "INITCOMPLETESUCCESS" => 1, "LoadStart" => 1, "Init" => 1, "InitDone" => 1, "Status" => 1, ); my $debug = 0; open BOOTLOG, "<C:\\bootlog.txt" or die ("Error: could not open c:\\bo +otlog.txt\n$!\n"); # Open up the file while (<BOOTLOG>) { my $readline = $_; chomp; my ( $key, $val); s/^\[\w*\]\s*//; # ditch the [A000134] junk for ease of splitting if ( /=/ ) { # lines w/ '=' have just 2 parts ( $key, $val ) = split(/\s+=\s+/); } else { # lines w/o '=' are key words ... value; e.g. value is the last word (my @key_val ) = split(/ /); $val = pop @key_val; $key = join " ", @key_val; } print "$readline" unless ($aok{$key}); # Check against %aok if its i +gnorable; if not, print. #print "$key = $val\n" unless ($aok{$key}); # if don't care about th +e "[mem addr]" part }
Not as nifty as it could be but faster.

a


Comment on Re: bootlog.txt shrinker
Select or Download Code
Re: Re: bootlog.txt shrinker
by dmckee (Scribe) on Mar 11, 2001 at 03:22 UTC
    Thanks... I'm looking into your code now: there's a lot I don't understand in there (like the indexing by key) but I'll have a good look.

    I could probably have just searched for lines containing FAIL (any case) but wasn't sure if that'd fail to report some other errors.

      Nothing special, its just a way to speed up searches when you have well defined search keys. You can do:
      $search_for = 'Failed|Ugly|Broken'; while (<LOG>) { print if /$search_for/; ...
      if you don't have a whole lot of items (or so I look at it, probably benchmarkably wrong) but if you've got a larger number, using a hash is a nice way to speed it up over the iterate through an array approach you used. It needs to be something like this, where the looked for text is consistent, though.

      The only other sneakiness (besides lopping of the initial memory (?) hex in brackets part to make the split-ing easier) was to see that there were 2 kinds of data lines; one w/ an = and variable left-hand side words and one w/o the = and the last word always being the 'result'.

      'course I wrote the mess before recognizing that you were printing unless the data matched a list item.

      a

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2014-09-17 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (95 votes), past polls