okay, here is more of my code. a simple link checker:
$tasks{$URL} = $URL; while (keys(%tasks) != 0) { foreach $key (keys (%tasks)) { if (!$opt_v) { print "#"; } else { print "checking $key\n"; } check_page($key); delete $tasks{key}; } } sub check_page{ unless (defined ($content = get $_[0])) { print "\n\n NASTY ERROR! \n\n bad link: $_[0]\n\n\n"; return; } my $parser = XML::Parser->new(ErrorContext => 2, Style => "Tree"); my $xso = XML::SimpleObject->new( $parser->parse($content) ) or die +"could not parse!"; check_tag($xso); # output the information foreach $file (keys %soundfiles) { print "\n BAD ".$file." called in $_[0]\n"; } foreach $link (keys %links) { next if make_url($link) =~ /$_[0]/ ; next if $link =~ /^#/ ; $tasks{make_url($link)} = make_url($link); print "checking ".make_url($link)."\n"; } } sub check_tag{ foreach my $tag($_[0]->children()) { if ($tag->name =~ /audio/) { build_audio($tag); } if ($tag->name =~ /goto/) { $links{$tag->attribute('next')} = "goto"; } check_tag($tag); } } sub make_url { if ($_[0] =~ /http:/) { return $_[0]; } elsif ($_[0] =~ /^#/) { return $_[0]; } else { return $base_url.$_[0]; } } sub build_audio { if (!exists $soundfiles{$_[0]->attribute('src')}) { unless (head(make_url($_[0]->attribute('src')))) { $soundfiles{make_url($_[0]->attribute('src'))} = "BAD"; } } }

In reply to Re: Re: Re: looping over xml by Micz
in thread looping over xml by Micz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.