in reply to HTML stripper in WWW::Mechanize doesn't seem to work
The @stripped_html is an array, just like you need. But $stripped_html[$x] is only one element in that array, which means that it's really a scalar1. Since the content sub returns an array, you're trying to assign an array to a scalar, and you'll end up with the number of things in the array.
You'll need to change your code a bit.
As is, this code prints out the HTML contents twice. Just so you can see the different ways to print an array, which wasn't your question so I'll stop blathering on about that now.# Note that the $x isn't needed with this approach, # so I took it out. my @stripped_html; @stripped_html = $webcrawler->content( format => "text" ); # You can print the array directly, like this: print @stripped_html; # Or put it in a loop to specify what you want between # the array elements: for my $item (@stripped_html) { print "$item\n"; }
1 Yes, it could be another array or a hash or whatever, I'm talking simplest case scenario here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTML stripper in WWW::Mechanize doesn't seem to work
by polettix (Vicar) on Aug 01, 2005 at 00:32 UTC | |
|
Re^2: HTML stripper in WWW::Mechanize doesn't seem to work
by lampros21_7 (Scribe) on Aug 01, 2005 at 01:21 UTC | |
by Nkuvu (Priest) on Aug 01, 2005 at 02:19 UTC | |
by sk (Curate) on Aug 01, 2005 at 03:49 UTC | |
by Nkuvu (Priest) on Aug 01, 2005 at 04:20 UTC |