http://www.perlmonks.org?node_id=999432


in reply to Re: Expat.pm and Parser.pm errors
in thread Expat.pm and Parser.pm errors

I did not included all the IF but here is it

if ($ARGV[$count] =~ "casoUso") { print "$count\n"; print "$ARGV[$count]\n"; $string0 = $ARGV[$count]; print "$string0\n"; print "mkdir $string0.dir\n"; ###gets the filename from the AR +G given from the command line run. system ("mkdir $string0.dir"); ###gets the filename from the A +RG given from the command line run. print "/usr/bin/unzip $ARGV[$count] -d ./$ARGV[$count].dir\n"; + ###gets the filename from the ARG given from the command line run. system ("/usr/bin/unzip $ARGV[$count] -d ./$ARGV[$count].dir") +; ###gets the filename from the ARG given from the command line run. $string1 = "./".$string0.".dir"."/word/document.xml"; print "$string1\n"; # print "$count\n"; # print "$ARGV[$count]\n"; # system ("mkdir ($ARGV[$count].dir)"); ###gets the filename fr +om the ARG given from the command line run. # system ("'/usr/bin/unzip' '$ARGV[$count]' -d './$ARGV[$count] +.dir'"); ###gets the filename from the ARG given from the command lin +e run. # use XML::Parser; # use LWP::Simple; # used to fetch the chatterbox ticker $cb_ticker = get("$string1"); # $cb_ticker = exec ("cat $string1"); print "paso cb ticker\n"; my $parser = new XML::Parser ( Handlers => { # Creates our p +arser object Start => \&hdl_start, End => \&hdl_end, Char => \&hdl_char, Default => \&hdl_def, }); print "paso parser\n"; $parser->parse($cb_ticker); print "paso parser2\n"; # The Handlers sub hdl_start{ my ($p, $elt, %atts) = @_; return unless $elt =~ m/'RF'/; # We're only interrested i +n what's said $atts{'_str'} = ''; $message = \%atts; for ($count = 1; $count <= $ARGV[4]; $count++) { if (($message =~ "CU$count ,") or ($message =~ "CU$count," +)) { for ($count2 = 1; $count2 <= $ARGV[4]; $count2++) { if (($array2[$count][1] =~ "RF$count.$count2 ") or + ($array2[$count][1] =~ "RF$count.$count2,") or ($array2[$count][1] = +~ "RF $count.$count2,") or ($array2[$count][1] =~ "RF $count.$count2 +,")) { $array2[$count][2]=$message; ### captures RF n +umber to array } } } } } sub hdl_end{ my ($p, $elt) = @_; format_message($message) if $elt =~ m/'CU'/ && $message && + $message->{'_str'} =~ /\S/; } sub hdl_char { my ($p, $str) = @_; $message->{'_str'} .= $str; } sub hdl_def { } # We just throw everything else sub format_message { # Helper sub to nicely format what we got + from the XML my $atts = shift; $atts->{'_str'} =~ s/\n//g; my ($y,$m,$d,$h,$n,$s) = $atts->{'time'} =~ m/^(\d{4})(\d{ +2})(\d{2})(\d{2})(\d{2})(\d{2})$/; # Handles the /me $atts->{'_str'} = $atts->{'_str'} =~ s/^\/me// ? "$atts->{'author'} $atts->{'_str'}" : "<$atts->{'author'}>: $atts->{'_str'}"; $atts->{'_str'} = "$h:$n " . $atts->{'_str'}; print "$atts->{'_str'}\n"; undef $message; } }

Replies are listed 'Best First'.
Re^3: Expat.pm and Parser.pm errors
by runrig (Abbot) on Oct 16, 2012 at 22:13 UTC
    It is best to post as little code as possible that actually runs (and that anyone can run) and demonstrates your problem (stating the output you got and the output you expected). Again, "as little code as possible, that runs as a standalone test case". Do you have a small test case? Often, by the time you cut it down to a small test case, you've solved your problem.