Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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/Simple.pm 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 rmtag.pl line 5. BEGIN failed--compilation aborted at rmtag.pl 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; } }
some_file.html
<html> <head><title>Some title</title></head> <body> <h1>Hello World</h1> How are you <p>New paragraph and stuff </body> </html>
Thank you.

Comment on how to remove HTML tag
Select or Download Code
Re: how to remove HTML tag
by moritz (Cardinal) on Mar 19, 2009 at 14:10 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 marto (Chancellor) on Mar 19, 2009 at 14:12 UTC
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/Simple.pm. 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://751724]
Approved by olus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2014-08-21 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (128 votes), past polls