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.
In reply to Re: HTML stripper in WWW::Mechanize doesn't seem to work
by Nkuvu
in thread HTML stripper in WWW::Mechanize doesn't seem to work
by lampros21_7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |