Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Expat.pm and Parser.pm errors

by runrig (Abbot)
on Oct 16, 2012 at 21:55 UTC ( [id://999431]=note: print w/replies, xml ) Need Help??


in reply to Expat.pm and Parser.pm errors

If that's all your script prints then you have serious problems. You have a lot of print statements and very little output. But then I don't see any hdl_* subroutines so maybe that's your problem. Or maybe your input to one of the functions is not what you think it is. Or maybe there's a problem on line 42.

Replies are listed 'Best First'.
Re^2: Expat.pm and Parser.pm errors
by jpinones (Initiate) on Oct 16, 2012 at 21:59 UTC

    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; } }
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://999431]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-04-23 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found