Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Expat.pm and Parser.pm errors

by jpinones (Initiate)
on Oct 16, 2012 at 21:59 UTC ( #999432=note: print w/ replies, xml ) Need Help??


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


Comment on Re^2: Expat.pm and Parser.pm errors
Download Code
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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-07-12 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (238 votes), past polls