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.

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 (Archbishop) 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/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?
[Discipulus]: but is really necessary to support these ancient versions? from 5.14 onward is not enough?
[Discipulus]: yes marto I understood
[Corion]: Discipulus: I'm slowly migrating my code to require 5.8.x ;) Most of my code works on 5.6, but Filter::signatures requires 5.10 I think
[Corion]: 5.14 is also a good target, widely available and fairly stable. Also, over five years old, which doesn't push people into a needless upgrade cycle
[Discipulus]: yes I saw your efforts Corion but the pain is worth?
[Corion]: Discipulus: IMO it's not that much pain, but most of the systems I use have a Perl 5.14 or newer on them nowadays
[marto]: the question is more, is Padre still the way new users should be directed?
[Discipulus]: ah ah I have all 5.26 atm but I play alone..
[Corion]: Except this RHEL box, which comes with Perl 5.10.1 , but there I installed my own 5.20.3 for the real Perl programs we run ;)
[Corion]: marto: I used Padre for some time but then switched to Notepad++, since all the funky features I wanted to put into Padre couldn't be made to work, and/or I lost interest :)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2018-06-25 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?