#!/usr/bin/perl -w package DumpSec; use XML::Parser; use strict; my %cur_entry; my $in_tag; my $p = new XML::Parser( Handlers => { Start => \&handle_start, End => \&handle_end, Char => \&handle_char, } ); $p->parsefile($_) for @ARGV; # -------------------------------------------------------------------- sub handle_start { my ($p, $el, %atts) = @_; if ($el eq 'entry') { %cur_entry = (); } if (grep {$el eq $_} qw(eventtime itemid security allowmask)) { $in_tag = $el; } } sub handle_end { my ($p, $el) = @_; $in_tag = undef; if ($el eq 'entry') { dump_sec(\%cur_entry); } } sub handle_char { my ($p, $el) = @_; $cur_entry{$in_tag} = $el if $in_tag; } # -------------------------------------------------------------------- sub dump_sec { my ($event) = @_; #printf '[%s] %9d: %-7.7s %032b' => printf '[%s] %d %s %d' . "\n" => $event->{eventtime}, cook_itemid($event), $event->{security} || "public", $event->{allowmask}; }