in reply to Re: Perl HTML::Tidy
in thread Perl HTML::Tidy

Thanks for pointing me at the additional documentation. I just installed Alien::TidyP and HTML::Today and have the following non working code. It's not grabbing any files yet. I'll continue to work on it:

use HTML::Tidy; my $call_dir = "/Users/joe/desktop/Test8"; #my $tidy = HTML::Tidy->new( {config_file => 'path/to/config'} ); my @files = glob "$calls_dir/*.hmtl"; printf "Got %d files\n", scalar @files; for my $file (@files) { open my $in_fh, '<', $file; $tidy->ignore( type => TIDY_WARNING, type => TIDY_INFO ); $tidy->parse( $file, $contents_of_file ); for my $message ( $tidy->messages ) { print $message->as_string; } }

Replies are listed 'Best First'.
Re^3: Perl HTML::Tidy
by poj (Abbot) on Feb 02, 2016 at 08:20 UTC

    You have a couple of typos - have a look at Use strict and warnings

    my @files = glob "$calls_dir/*.hmtl"; # should be $call_dir and 'html'

    I don't think this does what you think

    $tidy->parse( $file, $contents_of_file )

    From the docs :

    parse( $filename, $str [, $str...] ) Parses a string, or list of strings, that make up a single HTML file. The $filename parm is only used as an identifier for your use. The file is not actually read and opened.

    Try instead

    open my $in_fh, '<', $file or die "Could not open $file : $!"; my $contents_of_file = do { local $/;<$in_fh> }; close $in_fh; $tidy->parse( $file, $contents_of_file ) or warn "Error parsing $file :$!";
    poj

      Thanks very much poj. I'm much closer to getting it working. What you replied with was very helpful. I'll keep at it.