Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

how to remove HTML tag

by noor78 (Initiate)
on Mar 19, 2009 at 14:08 UTC ( #751724=perlquestion: print w/replies, xml ) Need Help??
noor78 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I am fairly new to perl. I have to run this simple code which is supose to remove tags from the attached some_file.html. But I get the following error:
Can't locate HTML/TokeParser/ in @INC (@INC contains: /etc/pe +rl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/per +l5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/ +lib/site_perl .) at line 5. BEGIN failed--compilation aborted at line 5.
#!/usr/bin/perl -w use strict; use HTML::TokeParser::Simple; RemoveTags("some_file.html"); sub RemoveTags { my $html_doc=shift; my $p = HTML::TokeParser::Simple->new ($html_doc); while ( my $token = $p->get_token ) { print $token->as_is if $token->is_text; } }
<html> <head><title>Some title</title></head> <body> <h1>Hello World</h1> How are you <p>New paragraph and stuff </body> </html>
Thank you.

Replies are listed 'Best First'.
Re: how to remove HTML tag
by moritz (Cardinal) on Mar 19, 2009 at 14:10 UTC
Re: how to remove HTML tag
by marto (Bishop) on Mar 19, 2009 at 14:12 UTC
Re: how to remove HTML tag
by olus (Curate) on Mar 19, 2009 at 14:12 UTC

    The error message is telling you that perl can't find the module you are trying to use. Do you have HTML::TokeParser::Simple installed?

Re: how to remove HTML tag
by Anonymous Monk on Mar 19, 2009 at 15:03 UTC

    A thimble-ful of additional explanation might be useful here...

    When you use or require any external module, such as (in this case) HTML::TokeParser::Simple Perl must search for the appropriate module.

    As you can see, the package-name above strongly implies that there's some kind of hierarchical, directory-like structuring going on, and in fact this is so. Perl will be looking for HTML/TokeParser/ But where will it look?

    The short-and-incomplete answer is that it will iterate through a list-type variable, @INC, looking in each of these places for the directory/file in question. There are several ways to determine what's in that list, including use lib directives, the PERL5LIB environment-variable, and a predefined starter list which is built-in to Perl itself. You can use the command, perl -V (note the capital “V”) to display, among other things, the contents of this list.

    Under your circumstances, I would say that it's fairly certain that the module you're looking for is not yet installed anywhere. There are, as you will soon see, several alternatives for how-and-where you may do so.

      The @INC list is given as part of the error message, so it's pretty easy to see what's currently in the list.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://751724]
Approved by olus
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-03-23 21:23 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (296 votes). Check out past polls.