I'd use next if $token->is_tag('a'); instead, but you really wanna combine your snippets, something like
use HTML::TokeParser::Simple; use strict; for(@ARGV){ my $p = HTML::TokeParser::Simple->new($_); my $hrefCount = 0; print "STRIPPING A-HREF TAGS in '$_'. PLEASE WAIT..\n"; open(TEMPO,">$_.tempo) or die "coudln't create $_.tempo($!)"; while(defined( my $t = $p->get_token() )){ if( $t->is_start_tag('a') ){ my $attr = $t->return_attr; if(exists $attr->{href}) { $hrefCount++; print "\nHREF TAG-->[$hrefCount]-->", $t->return_attr->{href},"\n\n"; } next; } elsif( $t->is_end_tag('a') ) { next; } else { print TEMPO $t->as_is; } } close(TEMPO); rename "$_.tempo", $_ or warn "couldn't rename '$_.tempo' to '$_'" +; }
|
MJD says you can't just make shit up and expect the computer to know what you mean, retardo! ** The Third rule of perl club is a statement of fact: pod is sexy. |
In reply to Re: Re: Is there a faster / more efficient / quicker or easier way to do this ?
by PodMaster
in thread Stripping a-href tags from an HTML document
by keyDemun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |