473,503 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perl HTML Parser does not work

10 New Member
Hi!

If I want to parse this html file (e.g. copy it into an other file using HTML Parser) I only get an empty file.
What am I doing wrong?
Thank you for your answer in advance.

Gábor
Aug 23 '08 #1
5 2256
szepesg
10 New Member
I forgot to mention that if I am working with a much simpler file e.g. an HTML file that has only 5 or 6 rows then everything is fine.

Gábor
Aug 23 '08 #2
KevinADC
4,059 Recognized Expert Specialist
See where my finger is pointing? That is where you are making a mistake.
Aug 23 '08 #3
eWish
971 Recognized Expert Contributor
Showing use the code would result in KevinADC not having to use his fingers.

--Kevin
Aug 24 '08 #4
szepesg
10 New Member
Hello,

This is the code I used:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2.  
  3.  use strict;
  4.  
  5.  
  6.  # define the subclass
  7.  package IdentityParse;
  8.  use base "HTML::Parser";
  9.  
  10.  open(OUT,">placid.html");
  11.  
  12.  sub text {
  13.      my ($self, $text) = @_;
  14.      # just print out the original text
  15.      print OUT $text;
  16.  }
  17.  
  18.  #sub comment {
  19.   #   my ($self, $comment) = @_;
  20.    #  # print out original text with comment marker
  21.     # print OUT "";
  22. # }
  23.  
  24.  sub start {
  25.      my ($self, $tag, $attr, $attrseq, $origtext) = @_;
  26.      # print out original text
  27.      print OUT $origtext;
  28.  }
  29.  
  30.  sub end {
  31.      my ($self, $tag, $origtext) = @_;
  32.      # print out original text
  33.      print OUT $origtext;
  34.  }
  35.  my $p = new IdentityParse;
  36.  $p->parse_file("index.html");
  37.  
Thank you for your help in advance:

Gábor
Aug 24 '08 #5
szepesg
10 New Member
Hello Guys,

It was all my mistake. The file's name I wanted to parse was x.htm and not x.html.
Sorry for bothering the forum.
I am new to perl I thought that there is a much complex problem.
Sorry again.

Gábor
Aug 24 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

42
4028
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
2
4381
by: Neal | last post by:
I need to know how to pass a parameter from PERL to an XSLT when using that XSLT to transform XML. For instance, I'd like to pass a paramter that I retrieve from the queryString and pass it into...
13
2461
by: Jesse Thompson | last post by:
Greetings fell XML folk. I've just gotten started making SAX filters in Perl. I was hoping to build an XML templating engine this way, but the performance of XML::SAX::Expat and XML::SAX::Writer...
2
2556
by: zzapper | last post by:
Hi am XML newbie This is the XML that is returned from a distant server, I can process it with standard Perl to get the data I want, but I know I ought to be able to use a Perl Module such as...
5
17130
by: Bob MacBob | last post by:
Hi all, I have two scripts: 1/ parser.pl which parses a text file and stuffs the relevant data into a mySQL DB - works fine no probs there 2/ importer.pl which I want to run through all the...
0
9734
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
21
34323
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
1676
by: bhavanirayala | last post by:
Hello, I am using XML::Parsar in my perl file. but when I run the perl file, getting the following erro even I have the parser.pm and Dynaloader.pm files in the lib path. The error is: Can't...
1
47347
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.