daseme has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w # turn on perl's safety features use strict; use diagnostics; use HTML::TokeParser::Simple; #define variable my $dirname="./"; my @files=undef; my $file=undef; my $newcontent=undef; opendir(DIR, $dirname) or die "can't opendir $dirname: $!"; @files = readdir(DIR); closedir(DIR); foreach $file (@files) { if($file =~ /\.html$/ && -T $file) { # do something with "$dirname/$file" my $stream = HTML::TokeParser::Simple->new($file) || die "Couldn't + read file $file: $!"; print "\n\nProcessing $file\n\n"; open FH, ">", $file or die "Error writing '$file': $!\n"; while ( my $token = $stream->get_token ) { if (( $token->is_comment and $token->as_is eq '<!--Sta +rt FULL TEXT-->') .. ($token->is_comment and $token->as_is eq '<!--End FULL TEX +T-->')){ $newcontent = $token->as_is; #if $token->is_text; print $newcontent; print FH $newcontent; } } close FH; } } exit(0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print inside while using HTML::TokeParser::Simple;
by friedo (Prior) on Apr 28, 2005 at 21:51 UTC | |
by daseme (Beadle) on Apr 28, 2005 at 22:05 UTC | |
by friedo (Prior) on Apr 28, 2005 at 22:18 UTC | |
by daseme (Beadle) on Apr 28, 2005 at 22:26 UTC |