473,657 Members | 2,801 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 2259
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
4075
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. I'm not interested on which language is better in *general*, just for my purpose. My area of research is in CAD algorithms, and I'm sensing the need to resort to something more expedient than C++, bash scripting, or sed scripting.
2
4391
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 XSLT which will create my HTML. Here's what I have for the basic transformation: #!/usr/local/bin/perl use XML::XSLT;/
13
2474
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 *appear* to be unthinkably bad. This code: XML::SAX::Expat->new(Handler => XML::SAX::Writer->new( Output => '>-' ))->parse_uri("test.xml");
2
2561
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 XML::Simple to dump into a Perl structure automatically, except I can't get it to work. My xml data is in $xml= $ua->request($req)->as_string;
5
17134
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 relevant files in a directory and run them through parser.pl
0
9738
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. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
21
34385
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 obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
1
1680
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 load '/usr/local/lib/perl5/site_perl/5.6.1/aix/auto/XML/Parser/Expat/Expat.so' for module XML::Parser::Expat: dlopen: /usr/local/lib/perl5/site_perl/5.6.1/aix/auto/XML/Parser/Expat/Expat.so: A file or directory in the path name does not exist. at...
1
47445
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 on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.