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 ARG given from the command line run. system ("mkdir $string0.dir"); ###gets the filename from the ARG 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 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. # 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 parser 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 in 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 number 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; } }