The code works well except now I'm getting a Segmentation Fault when I run the script. It occurs after my data has been printed, hangs for a while then throws the error message. This only happens on the XML files over 10mb. The small one doesn't get this error. Here's what the code looks like:
Any ideas why i'm getting this error? Or even a way to trace what part of the file or code it's occuring at?use strict; use warnings; use XML::Twig; use vars qw/ %options /; use Getopt::Std; use Switch; #---- #Code to treat the file #---- my $t = XML::Twig->new( twig_handlers => { object => \&animal_handler } ); $t->parsefile($File); sub animal_handler { my ($t, $obj) = @_; if ($obj->att('type') eq 'dog') { my $name; my $id; my $bname; for my $prop ($obj->children('property')) { $name = $prop->att('value') if $prop->att('name') eq 'nam +e'; $id = $prop->att('value') if $prop->att('name') eq 'dog +_breed_id'; $gname = $prop->att('value') if $prop->att('name') eq 'dog +_breed_name'; } print "$id,$name,$bname\n"; } }
In reply to Re^2: XML::Parser using stream
by Falantar
in thread Solved: XML::Parser using stream (used XML:Rules)
by Falantar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |