[24176] in Perl-Users-Digest
Perl-Users Digest, Issue: 6368 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 6 11:05:45 2004
Date: Tue, 6 Apr 2004 08:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 6 Apr 2004 Volume: 10 Number: 6368
Today's topics:
command line <anonymous@disneyland.com>
Re: command line <wherrera@lynxview.com>
Re: command line <anonymous@disneyland.com>
Re: command line <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: command line <anonymous@disneyland.com>
Re: command line <dwilga-MUNGE@mtholyoke.edu>
Re: command line <wherrera@lynxview.com>
Re: command line <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: command line <anonymous@disneyland.com>
Re: command line <jurgenex@hotmail.com>
Re: command line <jtc@shell.dimensional.com>
Re: How read email headers? <vek@station02.ohout.pharmapartners.nl>
Re: How read email headers? <gp@nospm.hr>
Re: Loss of privledges in a perl app <simon.andrews@bbsrc.ac.uk>
Re: Module compilation misery <simon.andrews@bbsrc.ac.uk>
Need help with implementing fwdport example from Perl C <paul@lanifex.com>
Passing/saving file descriptors between processes (Kevin)
Re: Possible to open a Berkeley 4.2 db file with DB_Fil <Paul.Marquess@btinternet.com>
Re: real, simple sample OOP intro text??!! <geoffacox@dontspamblueyonder.co.uk>
Re: real, simple sample OOP intro text??!! <tassilo.parseval@rwth-aachen.de>
Re: striptag (Himanshu Garg)
Re: Tough (for me) regex case <moggadah@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Apr 2004 12:39:30 GMT
From: "luc" <anonymous@disneyland.com>
Subject: command line
Message-Id: <6yxcc.61968$2S4.4164712@phobos.telenet-ops.be>
I am trying to understand perls command line in dos(xp). I would simple want
to send hello to the screen. I've tried things like: perl -ew "print
\"hello\";"
perl -ew "print 'hello';"
What are perls rules here in the dos command line? Is there any
site/tutorial on this subject?
------------------------------
Date: Tue, 06 Apr 2004 06:47:53 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: command line
Message-Id: <z-mdnaqQCMKEOu_dRVn-sA@adelphia.com>
luc wrote:
> I am trying to understand perls command line in dos(xp). I would simple want
> to send hello to the screen. I've tried things like: perl -ew "print
> \"hello\";"
> perl -ew "print 'hello';"
> What are perls rules here in the dos command line? Is there any
> site/tutorial on this subject?
>
>
From the ActiveState perl docs:
-----
Why doesn't 'perl -e' work?
It does - it's just that some command shells (for example COMMAND.COM,
CMD.EXE and 4DOS) don't accept single quotes wrapped around command
arguments.
The safest way to do perl one-liners is to wrap the parameters within ""
(double-quotes) the use q() and qq() inside the parameters. q() and qq()
with put whatever is inside them between single-quotes or double-quotes,
respectively.
For example:
perl -e "use LWP::Simple; while(@c = head <>) { $c = join qq(\n\t), @c;
print qq(Header info:\n\t$c\n); }"
(this was all one line)
---
hth
------------------------------
Date: Tue, 06 Apr 2004 12:51:41 GMT
From: "luc" <anonymous@disneyland.com>
Subject: Re: command line
Message-Id: <xJxcc.61976$ER4.4147232@phobos.telenet-ops.be>
"Bill" <wherrera@lynxview.com> schreef in bericht
news:z-mdnaqQCMKEOu_dRVn-sA@adelphia.com...
> luc wrote:
> > I am trying to understand perls command line in dos(xp). I would simple
want
> > to send hello to the screen. I've tried things like: perl -ew "print
> > \"hello\";"
> > perl -ew "print 'hello';"
> > What are perls rules here in the dos command line? Is there any
> > site/tutorial on this subject?
> >
> >
> From the ActiveState perl docs:
> -----
> Why doesn't 'perl -e' work?
> It does - it's just that some command shells (for example COMMAND.COM,
> CMD.EXE and 4DOS) don't accept single quotes wrapped around command
> arguments.
>
> The safest way to do perl one-liners is to wrap the parameters within ""
> (double-quotes) the use q() and qq() inside the parameters. q() and qq()
> with put whatever is inside them between single-quotes or double-quotes,
> respectively.
> For example:
>
> perl -e "use LWP::Simple; while(@c = head <>) { $c = join qq(\n\t), @c;
> print qq(Header info:\n\t$c\n); }"
>
> (this was all one line)
>
> ---
>
> hth
So, how can I put the word hello to the screen in a one liner then?
------------------------------
Date: Tue, 6 Apr 2004 14:58:11 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: command line
Message-Id: <Xns94C3978013BECelhber1lidotechnet@62.89.127.66>
"luc" <anonymous@disneyland.com> wrote:
> I am trying to understand perls command line in dos(xp). I would
> simple want to send hello to the screen. I've tried things like:
> perl -ew "print \"hello\";"
> perl -ew "print 'hello';"
> What are perls rules here in the dos command line? Is there any
> site/tutorial on this subject?
Change -ew to -we in both examples. For more information:
perldoc perlrun
--
Cheers,
Bernard
------------------------------
Date: Tue, 06 Apr 2004 13:13:18 GMT
From: "luc" <anonymous@disneyland.com>
Subject: Re: command line
Message-Id: <O1ycc.61986$OR4.4157509@phobos.telenet-ops.be>
"Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> schreef in
bericht news:Xns94C3978013BECelhber1lidotechnet@62.89.127.66...
> "luc" <anonymous@disneyland.com> wrote:
>
> > I am trying to understand perls command line in dos(xp). I would
> > simple want to send hello to the screen. I've tried things like:
> > perl -ew "print \"hello\";"
> > perl -ew "print 'hello';"
> > What are perls rules here in the dos command line? Is there any
> > site/tutorial on this subject?
>
>
> Change -ew to -we in both examples. For more information:
>
>
> perldoc perlrun
>
>
> --
> Cheers,
> Bernard
Thanks Bernard.
So if you would like to rename a list of files with a .txt extension to a
.pl extension, you could use the following command: print -we "rename
'*.txt','*.pl';"? This however doesn't work. How can you rename a series of
files(without using the default variable!) in a one liner?
------------------------------
Date: Tue, 06 Apr 2004 09:13:53 -0400
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: command line
Message-Id: <dwilga-MUNGE-303EE4.09135306042004@nap.mtholyoke.edu>
In article <6yxcc.61968$2S4.4164712@phobos.telenet-ops.be>,
"luc" <anonymous@disneyland.com> wrote:
> I am trying to understand perls command line in dos(xp). I would simple want
> to send hello to the screen. I've tried things like: perl -ew "print
> \"hello\";"
> perl -ew "print 'hello';"
> What are perls rules here in the dos command line? Is there any
> site/tutorial on this subject?
IMHO, your best bet is to get a real commandline interpreter, like any
Unixy shell under Cygwin:
http://www.cygwin.com
--
Dan Wilga dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **
------------------------------
Date: Tue, 06 Apr 2004 07:30:45 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: command line
Message-Id: <kMKdnUg3Lc65LO_dRVn-iQ@adelphia.com>
luc wrote:
> So, how can I put the word hello to the screen in a one liner then?
Do you have ActiveState's perl HTML docs?
perl -e "print qq(hello\n);"
------------------------------
Date: Tue, 6 Apr 2004 15:56:30 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: command line
Message-Id: <Xns94C3A163CD7B7elhber1lidotechnet@62.89.127.66>
"luc" <anonymous@disneyland.com> wrote:
>
> "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
> schreef in bericht
> news:Xns94C3978013BECelhber1lidotechnet@62.89.127.66...
>> "luc" <anonymous@disneyland.com> wrote:
>>
>> > I am trying to understand perls command line in dos(xp). I
>> > would simple want to send hello to the screen. I've tried
>> > things like: perl -ew "print \"hello\";"
>> > perl -ew "print 'hello';"
>> > What are perls rules here in the dos command line? Is there any
>> > site/tutorial on this subject?
>>
>>
>> Change -ew to -we in both examples. For more information:
>>
>>
>> perldoc perlrun
>
> Thanks Bernard.
> So if you would like to rename a list of files with a .txt
> extension to a .pl extension, you could use the following command:
> print -we "rename '*.txt','*.pl';"? This however doesn't work. How
> can you rename a series of files(without using the default
> variable!) in a one liner?
I understand nothing of what you just said, except that you want to
rename some files, which has nothing to do with Print...I mean Perl.
--
Cheers,
Bernard
------------------------------
Date: Tue, 06 Apr 2004 14:04:46 GMT
From: "luc" <anonymous@disneyland.com>
Subject: Re: command line
Message-Id: <2Oycc.62029$oR4.4130880@phobos.telenet-ops.be>
"Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> schreef in
bericht news:Xns94C3A163CD7B7elhber1lidotechnet@62.89.127.66...
> "luc" <anonymous@disneyland.com> wrote:
>
> >
> > "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
> > schreef in bericht
> > news:Xns94C3978013BECelhber1lidotechnet@62.89.127.66...
> >> "luc" <anonymous@disneyland.com> wrote:
> >>
> >> > I am trying to understand perls command line in dos(xp). I
> >> > would simple want to send hello to the screen. I've tried
> >> > things like: perl -ew "print \"hello\";"
> >> > perl -ew "print 'hello';"
> >> > What are perls rules here in the dos command line? Is there any
> >> > site/tutorial on this subject?
> >>
> >>
> >> Change -ew to -we in both examples. For more information:
> >>
> >>
> >> perldoc perlrun
> >
> > Thanks Bernard.
> > So if you would like to rename a list of files with a .txt
> > extension to a .pl extension, you could use the following command:
> > print -we "rename '*.txt','*.pl';"? This however doesn't work. How
> > can you rename a series of files(without using the default
> > variable!) in a one liner?
>
>
> I understand nothing of what you just said, except that you want to
> rename some files, which has nothing to do with Print...I mean Perl.
>
>
> --
> Cheers,
> Bernard
sorry, typo...
So if you would like to rename a list of files with a .txt
extension to a .pl extension, you could use the following command:
perl -we "rename '*.txt','*.pl';"? This however doesn't work. How
can you rename a series of files(without using the default
variable!) in a one liner?
------------------------------
Date: Tue, 06 Apr 2004 14:14:11 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: command line
Message-Id: <TWycc.1675$hd3.607@nwrddc03.gnilink.net>
luc wrote:
> So if you would like to rename a list of files with a .txt extension
> to a .pl extension, you could use the following command: print -we
> "rename '*.txt','*.pl';"? This however doesn't work.
Assuming you meant to write
perl -we "rename '*.txt','*.pl';"
did you read the man page for the rename function? It will rename _one_
file!
Furthermore the DOS shell (in an earlier post you mentioned that you are on
Windows) doesn't know anything about wildcards. Therefore the '*' will not
be expanded as it would be on e.g. most Unix shells and as you seem to
expect. In other words you are trying to rename the file with the literal
name '*.txt'. I guess this is not what you want.
> How can you
> rename a series of files(without using the default variable!) in a
> one liner?
Well, you will have to use glob() and a loop to get the names of all the
files and then loop through them.
jue
------------------------------
Date: 6 Apr 2004 08:42:19 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: command line
Message-Id: <slrnc75geb.g7g.jtc@shell.dimensional.com>
In article <kMKdnUg3Lc65LO_dRVn-iQ@adelphia.com>, Bill wrote:
> luc wrote:
>
>> So, how can I put the word hello to the screen in a one liner then?
>
> Do you have ActiveState's perl HTML docs?
>
> perl -e "print qq(hello\n);"
>
Or install cygwin and use bash to do it the conventional way.
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
------------------------------
Date: 06 Apr 2004 07:08:38 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: How read email headers?
Message-Id: <slrnc74lrm.7en.vek@station02.ohout.pharmapartners.nl>
On 05 Apr 2004 23:40:55 GMT,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> Let me give you a little warning though: while 90% of the bounce
> messages are reasonably formatted, and easy to parse, and fall in a
> few categories, there are some cutesy mail admins out there, who've
> customised the crap out of their mail gateway, with the result that
> their bounce messages are almost impossible to recognise as such.
>
And as bounce messages are supposed be mime formatted you may consider
using a mime parser, such as MIMEtools also from CPAN.
Villy
------------------------------
Date: Tue, 6 Apr 2004 12:54:14 +0200
From: "PHP2" <gp@nospm.hr>
Subject: Re: How read email headers?
Message-Id: <c4u26s$db0$1@ls219.htnet.hr>
thanks
"Villy Kruse" <vek@station02.ohout.pharmapartners.nl> wrote in message
news:slrnc74lrm.7en.vek@station02.ohout.pharmapartners.nl...
> On 05 Apr 2004 23:40:55 GMT,
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>
>
> > Let me give you a little warning though: while 90% of the bounce
> > messages are reasonably formatted, and easy to parse, and fall in a
> > few categories, there are some cutesy mail admins out there, who've
> > customised the crap out of their mail gateway, with the result that
> > their bounce messages are almost impossible to recognise as such.
> >
>
> And as bounce messages are supposed be mime formatted you may consider
> using a mime parser, such as MIMEtools also from CPAN.
>
>
> Villy
------------------------------
Date: Tue, 06 Apr 2004 14:41:46 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Loss of privledges in a perl app
Message-Id: <c4uc2a$6ia$1@south.jnrs.ja.net>
lvirden@yahoo.com wrote:
>
> I inherited a perl app that runs setuid. The app was running okay, but
> recently, I discovered that when I tried to run it, I was getting a failure
> message about an inability to perform a specialized directory creation.
> When I added the line
> print system("id");
> the results indicated that there was no effective userid being set.
I got bitten by this last week :-)
The problem here is the distinction between effective user id ($>) and
the real user id ($<). Running a program suid seems to set $>, but not
$<. The effect of this is that the program drops its privileges when
you fork a new copy (eg via a system command).
The solution to this is to put a line at the top saying
$< = 0;
..or probably better (but not tested)
$< = $>;
Hope this helps
Simon.
------------------------------
Date: Tue, 06 Apr 2004 15:13:50 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Module compilation misery
Message-Id: <c4udue$72h$1@south.jnrs.ja.net>
Garry Heaton wrote:
> Please don't take this as a troll as I would like to hear how other Perl
> programmers deal with failed module compilation.
>
> Despite my love of Perl as a language I've had to give-up on it recently
> because module compilation is so hit and miss. I have experienced failed
> compilations of many modules lately on both Mac OSX Panther and Fedora Core
> 1 (DBD::mysql, HTML::Mason, mod_perl and others) such that I've had to
> resort to learning PHP to get work done without the need for endless module
> compilation.
I've installed numerous modules under Fedora Core 1 including some of
those you list above. If they fail it's nearly always because one of
the libraries they require is missing. Normally the error given will
tell you exactly what you need and a quick "yum install xxxx" will sort
it. The thing to watch for is that usually what the module needs is not
the binary excutables for a particular package, but the header files for
the library. So if for instance the Makefile for mysql says it can't
find the mysql files, this doesn't mean you need the mysql package, but
rather mysql-devel.
The other thing to be aware that for Fedora at least there are pre-built
packages for many of the common perl modules. In these cases you're
just a "yum install perl-Some-Module" away from it being up and running.
Try "yum search perl" to see what's out there already!
HTH
Simon.
------------------------------
Date: Tue, 06 Apr 2004 15:06:17 +0200
From: Paul Gillingwater <paul@lanifex.com>
Subject: Need help with implementing fwdport example from Perl Cookbook
Message-Id: <c4u9aa$2kj0tn$1@ID-209891.news.uni-berlin.de>
Hi there,
I am running Tom Christiansen's fwdport from page 637 of the Perl
Cookbook. It seems to run just fine, but as soon as the server closes
its connection (i.e., the one which is being forwarded to), then fwdport
also terminates.
My expected behaviour would be for the fwdport to simply sit there,
accept connections from the inside world, and forward them to the
outside. But it seems to die after the server closes -- with the
message "NOT REACHED" line 24. This suggests that the service_clients
subroutine is not looping indefinitely--and indeed, debugging seems to
show that it doesn't like something -- I see the message
"Bizarre kid 31114 exited 15" in my telnet client while testing.
Any ideas what could be the problem here? Is there another version of
fwdport which behaves as expected? Of course I already Googled for
fwdport, to no avail. Thanks in advance!
--
*********************************
Paul Gillingwater, BA, B.Sc, MBA
CISM, CISSP, Managing Director
CSO Lanifex Unternehmensberatung
& Softwareentwicklung G.m.b.H.
INFOSEC SERVICES
E-mail: paul@lanifex.com
Tel: +43(1)2198222-20
Fax: +43(1)2198222-11
Mobile: +43(699)1922 3085
Webhome: http://www.lanifex.com/
Address: Praterstrasse 66/1
A-1020 Vienna, Austria
*********************************
------------------------------
Date: 6 Apr 2004 07:17:32 -0700
From: leinfidel@netscape.net (Kevin)
Subject: Passing/saving file descriptors between processes
Message-Id: <50af122e.0404060617.7454f730@posting.google.com>
Hello,
I have a main processes that opens a number of file handles, keeps
track of the opened handles, then forks and execs different programs
that utilize them (usually i dup to stdin). Often I launch more than
one instance of a given program, and that instance will use the same
handle as its co process.
However if the main process keeping track of all these handles has to
restart, I lose all the open file handles. File descriptor numbers
are meaningless on a restart, so I don't think say data dumper is
going to do me any good.
In C, it's possible to pass this information to another process with
I_SENDFD and I_RECVFD ioctls on a STREAMS pipe. So that other process
could hold onto the data, and hand it back to the main process on
restart.
However that's a hassle, and would involve some XS/Inline code.
Is there some way to save/write out the true handle reference, so that
it could be reloaded on startup?
Thanks!
------------------------------
Date: Tue, 6 Apr 2004 09:22:19 +0100
From: "Paul Marquess" <Paul.Marquess@btinternet.com>
Subject: Re: Possible to open a Berkeley 4.2 db file with DB_File?
Message-Id: <c4tpbt$2mr9bm$1@ID-211855.news.uni-berlin.de>
"187" <bigal187.invalid@adexec.com> wrote in message
news:c4sq6l$2mau74$1@ID-196529.news.uni-berlin.de...
> "Paul Marquess" <Paul.Marquess@btinternet.com> wrote in message
> news:c4r7nl$2imvcm$1@ID-211855.news.uni-berlin.de...
> >
> > "187" <bigal187.invalid@adexec.com> wrote in message
> > news:c4klm9$2h7qo2$1@ID-196529.news.uni-berlin.de...
> > > Is it possible to open a Berkeley 4.2 db file with DB_File?
> > >
> > > It doesn't not seem to want to open:
> > >
> > > unless ($st = tie %db, "DB_File", 'somedbfile.db', O_RDONLY, 0640,
> > > $DB_HASH) {
> > > die "Cannot open file 'somedbfile.db': $!\n";
> > > }
> > >
> > > This code dies when I run it.
> > > (And curiously $! seems to be empty:
> > > Cannot open file 'somedbfile.db':
> > > )
> > >
> > > I did a db dump from the db file and heres the header:
> > >
> > > VERSION=3
> > > format=print
> > > database=a_test_db
> > > type=hash
> > > h_nelem=3
> > > db_pagesize=4096
> > >
> > > Is there any way to read this version of a berk db file in Perl?
> Thanks.
> > > (Google didn't give mcuh help either, I kept running into posts
> abotu
> > > using berk 1.* .)
> >
> > DB_File can read any Berkeley DB database file, as long as it has been
> built
> > with a compatible version of the Berkeley DB library. The Berkeley DB
> > database format has changed a number of times, so you need to make
> sure
> > DB_File has been built with the correct one.
> >
> > Run this to see what version of Berkeley DB your DB_File was built
> with.
> >
> > perl -e 'use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}'
> >
> > If you want to interoperate with a database file created with Berkeley
> DB
> > 4.2, you need to have built DB_File with Berkeley DB 4.1 or 4.2.
>
> Berkeley DB ver 3.003011
Then you need to build DB_File with a newer version of the Berkeley DB
library.
> Though I found a module BerkeleyDB.pm at cpan, works great for various
> versions, so much more flexible, and the beauty is that most of the
> syntax is similar, though with some aditions. Works great from my
> testing.
The story is exactly the same for my BerkeleyDB Perl module. If you need to
interoperate with a database created with a with a specific version of the
Berkeley DB library, you need to build my Perl module with a compatible
version of the Berkeley DB library.
Paul
------------------------------
Date: Tue, 06 Apr 2004 08:10:53 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: real, simple sample OOP intro text??!!
Message-Id: <sep4709lq9cfoglgrrim8epi6oidrn1bg7@4ax.com>
On 5 Apr 2004 21:06:02 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:
>Also sprach Geoff Cox:
>> On 4 Apr 2004 18:20:36 GMT, "Tassilo v. Parseval"
>><tassilo.parseval@rwth-aachen.de> wrote:
>>
>> Tassilo,
>>
>> having got to the point of having an OOP script that works for 1 html
>> file, is it possible to work with a series of similar files using
>> File::Find ? I am trying this but getting errors which I correct
>> yet...
>
>Sure, why not? What you can do once, you can do twice (and more times)
>as well. It's just a matter of calling '$parser->parse_file' for each
>file you want to process.
Tassilo,
Thanks for that - in fact have had some success with multiple files
now!
Cheers
Geoff
>Tassilo
------------------------------
Date: 6 Apr 2004 08:39:38 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: real, simple sample OOP intro text??!!
Message-Id: <c4tqca$mm8$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Geoff Cox:
> On 5 Apr 2004 21:06:02 GMT, "Tassilo v. Parseval"
><tassilo.parseval@rwth-aachen.de> wrote:
>
>>Also sprach Geoff Cox:
>>> On 4 Apr 2004 18:20:36 GMT, "Tassilo v. Parseval"
>>><tassilo.parseval@rwth-aachen.de> wrote:
>>>
>>> Tassilo,
>>>
>>> having got to the point of having an OOP script that works for 1 html
>>> file, is it possible to work with a series of similar files using
>>> File::Find ? I am trying this but getting errors which I correct
>>> yet...
>>
>>Sure, why not? What you can do once, you can do twice (and more times)
>>as well. It's just a matter of calling '$parser->parse_file' for each
>>file you want to process.
>
> Tassilo,
>
> Thanks for that - in fact have had some success with multiple files
> now!
Good. One thing you have to be careful with: When you use global
variables to keep track of the current state (like in which tag the
parser currently is), you need to reset them for each file.
That can be conveniently done by overriding the parse*() methods in your
parser subclass:
package MyParser;
use base qw/HTML::Parser/;
my $in_heading;
my $p;
# and possibly the same for parse() and parse_chunk()
# if you use those
sub parse_file {
my $self = shift;
($in_heading, $p) = (0, 0);
$self->SUPER::parse_file(@_);
}
sub start {
...
}
...
SUPER is a metapackage specifier. Since HTML::Parser::parse_file() is
overridden, it is no longer called when doing
$parser->parse_file(...);
In order to call it nonetheless after the resetting is done, this line
$self->SUPER::parse_file(@_);
refers to the superclass' parse_file() method. Using SUPER::method() is
a common way to call the original inherited method even when it has been
overridden by the subclass.
Once have you overridden these methods thusly, you no longer have to
worry when calling
$parser->parse_file("file.html");
because this method will now take care of resetting any global
variables.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 6 Apr 2004 00:47:12 -0700
From: himanshu@gdit.iiit.net (Himanshu Garg)
Subject: Re: striptag
Message-Id: <a46e54c7.0404052347.2bea8962@posting.google.com>
Dan Jacobson <jidanni@jidanni.org> wrote in message news:<87d66mm44e.fsf@jidanni.org>...
> This used to strip only the given tags:
> $ striptag font div < file.html
> but now it strips all tags. Something must have changed on my system. Help.
> $ cat striptag
> use strict;
> use HTML::Parser;
> my $parser = HTML::Parser->new( text_h => [ sub { print shift; },"dtext" ]);
> $parser->parse_file(*STDIN);
You probably deleted the code that handles the command line arguments.
Nowhere do I see special handling of ARGV which in this case is font
and div.
++imanshu
------------------------------
Date: Tue, 6 Apr 2004 13:21:08 +0200
From: "mortb" <moggadah@hotmail.com>
Subject: Re: Tough (for me) regex case
Message-Id: <OQZC9i8GEHA.3164@TK2MSFTNGP11.phx.gbl>
Sorry Brian,
I tested your expression "(?<no_quotes>(""|[^"])*)" and it also rendered
(1) "quick"
(2) "fox jumped ""over"" the"
thus still leaving the initial and ending quotes in the strings.
cheers,
mortb
"Rob Perkins" <rob_perkins@hotmail.com> wrote in message
news:4nmr60h82vnto36j69knmmtnspjd1fia85@4ax.com...
> "Brian Davis" <@> wrote:
>
> >
> >Does my earlier suggestion about using a named group not work?
>
>
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6368
***************************************