LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Quick perl question

[ILUG] Quick perl question

Niall O Broin niall at magicgoeshere.com
Mon Nov 29 16:04:26 GMT 2004


On 29 Nov 2004, at 14:59, Kevin Philp wrote:

> Can't call method "get_trimmed_text" on unblessed reference
>
> my $browser = LWP::UserAgent->new;
> my $url = "http://www.cybercolloids.net/index.php";
> my $response = $browser->get($url);
> 	die "Error at $url\n ", $response->status_line, "\n Aborting" unless
> $response->is_success;
>
> my $stream = HTML::TokeParser->new(\$response->content) || die "Cannot 
> open:
> $!";
>
> while (my $token = $stream->get_tag("a")) {
>             my $link = $token->[1]{href} || "-"; # ===OK
>             my $text = $token->get_trimmed_text("/a") || "-"; #===Not 
> OK
>              print "$link\t\n";
>          }

$token doesn't have a get_trimmed_text method. $token is whatever is 
returned by the get_tag method of $stream. What is $token (in perl 
terms) ? get_trimmed_text is a method of HTML::TokeParser so perhaps 
the line

> my $text = $token->get_trimmed_text("/a") || "-";

should actually be

my $text = $stream->get_trimmed_text("/a") || "-";



Niall




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell