Linux puskom-ProLiant-DL385-Gen10 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64
/
usr
/
share
/
doc
/
libxml-sax-expat-perl
/
examples
/
//usr/share/doc/libxml-sax-expat-perl/examples/counter.pl
#!/usr/bin/perl -w use strict; use warnings; use XML::SAX::Expat; sub Counter::new { bless { count => 0 }, shift } sub Counter::start_element { shift->{count}++ } if (@ARGV != 1) { print "Usage: $0 example.xml\n"; exit; } my $counter = Counter->new; my $parser = XML::SAX::Expat->new(Handler => $counter); $parser->parse_file($ARGV[0]); printf "%s has %d elements\n", $ARGV[0], $counter->{count};