well my script is done now but it's really slow.
i made another one that just parses the xmlfiles as if they were just textfiles.
that took about 4 seconds for 5 files, but using twig it takes 116 seconds...
this is my code :
::twig
sub readxml{
$xmlfile = shift;
my $twig= new XML::Twig(twig_handlers => { '/kvdt' => \&fall });
+
$twig->parsefile($xmlfile);
}
sub fall{
my( $twig, $element)= @_;
my @scheine = $element->get_xpath('.//*');
foreach my $schein (@scheine){
my $fk = $schein->name;
if ($schein->{att}->{USE}){($schein->{att}->{USE} =~ /EDV/)?(n
+ext):();}
if ($fk =~ /fk....\b/){
my $key = substr($fk,2,4);
$data{xml}{$key}++;
}
}
}
text
sub readxml{
$xmlfile = shift;
open(XML, $xmlfile);
while(<XML>){
chomp();
my $line = $_;
my @bla;
($line =~ /USE="EDV"/)?(next):();
if ($line =~ /<fk....[^_]/){
@bla = split(/<fk/,$line);
my $key = substr($bla[1],0,4); #30
$data{xml}{$key}++;
}
}
close(XML);
}
is there a way to make this faster using ::twig ?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.