Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perl HTML::Tidy

by GotToBTru (Prior)
on Feb 01, 2016 at 19:23 UTC ( [id://1154222]=note: print w/replies, xml ) Need Help??


in reply to Perl HTML::Tidy

What do you have so far?

But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Replies are listed 'Best First'.
Re^2: Perl HTML::Tidy
by Anonymous Monk on Feb 01, 2016 at 22:43 UTC

    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; } }

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1154222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-19 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found