1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#!/usr/local/bin/perl -w
use strict;
use Data::Stag qw(:all);
use Getopt::Long;
use Data::Dumper;
use FileHandle;
my $exec;
my $codefile;
my $parser = '';
my $writer = '';
my %trap = ();
my $help;
GetOptions(
"help|h"=>\$help,
);
if ($help) {
system("perldoc $0");
exit 0;
}
my $el = shift;
my $total = 0;
while (my $fn = shift @ARGV) {
my $n = 0;
my $H = Data::Stag->makehandler($el=>sub {
$n++;
return;
});
my @pargs = (-file=>$fn, -format=>$parser, -handler=>$H);
if ($fn eq '-') {
if (!$parser) {
$parser = 'xml';
}
@pargs = (-format=>$parser, -handler=>$H, -fh=>\*STDIN);
}
my $nu = Data::Stag->parse(@pargs);
print $nu->sxpr;
print "$fn: $n\n";
$total+=$n;
}
print "total:$total\n";
__END__
=head1 NAME
stag-elcount
=head1 SYNOPSIS
stag-elcount person/name myfile.xml
=head1 DESCRIPTION
gets a count of the number of elements
=over ARGUMENTS
=back
=cut
|