[13518] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 928 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 28 08:32:55 1999

Date: Tue, 28 Sep 1999 05:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <938520306-v9-i928@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 28 Sep 1999     Volume: 9 Number: 928

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
        can I pass control to a different program <bmpeters@houston.geoquest.slb.com>
    Re: DB_File (Anno Siegel)
    Re: DB_File <gellyfish@gellyfish.com>
    Re: Getting record as hash <nospam.newton@gmx.net>
    Re: HTML to ASCII (Bernhard Muenzer)
        I can't see the error (short bit of code) <daniel@vesma.co.uk>
    Re: I can't see the error (short bit of code) (Sam Holden)
    Re: Randomize array..... <rhomberg@ife.ee.ethz.ch>
    Re: Regex == Turing? (was remove the html tag in the fi (Anno Siegel)
    Re: remove the html tag in the file <skilchen@swissonline.ch>
        t <Paul.Hand@document.co.uk>
        Warning: Subroutine redefined (What to do ?) lesve@geocities.com
    Re: Warning: Subroutine redefined (What to do ?) (Sam Holden)
    Re: Warning: Subroutine redefined (What to do ?) <gellyfish@gellyfish.com>
    Re: Warning: Subroutine redefined (What to do ?) <rassmann@sdm.de>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 28 Sep 1999 10:24:01 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage938514241.28659@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 18 Aug 1999

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:

    setdir usenet-by-group/news.announce.newusers
    send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


------------------------------

Date: Wed, 22 Sep 1999 18:32:22 -0500
From: Bradley Peters <bmpeters@houston.geoquest.slb.com>
Subject: can I pass control to a different program
Message-Id: <37E96706.A4F29E16@houston.geoquest.slb.com>

Can somebody please tell me whether I can pass control to another
program within a PERL script.


Using a UNIX  csh   shell script I was able to pass control to a
different program as follows (using sqlplus as an example)
#!/bin/csh
sqlplus user/password  <<EOFone
show user;
exit;
EOFone


Can I do the same thing in Perl.





------------------------------

Date: 28 Sep 1999 09:47:42 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: DB_File
Message-Id: <7sq2ru$7c2$1@lublin.zrz.tu-berlin.de>

Joe Buhr  <joe.buhr@motorola.com> wrote in comp.lang.perl.misc:
>I think this should be a simple problem...  hopefully someon can point
>out my err right away, so here goes.
>
>I would like to use the perl DB_File module to store some data.  I'll
>show what I'm trying to do in to seperate scripts.  Here's the syntax:
>
>************************************
>#!/usr/misc/bin/perl

No -w.  No use strict.  Bat practice.

>use DB_File;
>
>tie %h, "DB_File", "test", O_RDWR|O_CREAT, 0644;

Always check tie for success.  It's like open in that respect.

>            $h{1} = "Joe";
>            $h{2} = "Ernie";
>            $h{3} = "Charly";
>            $h{4} = "Alex";
>            $h{5} = "Ted";
>            untie %h;
>************************************
>************************************
>#!/usr/misc/bin/perl
>
>use DB_File;
>
>tie %h, "DB_File", "test", O_RDWR|O_CREAT, 0644;

The same comments as above apply.  Moreover, why do you use O_CREAT
with a Database that already exists?

>            foreach (1,2,3,4,5) {
>                    print "$h{$_}\n";
>            }
>            untie %h;
>*************************************
>The file "test" gets created, but no data gets stored in it?  Is that
>right?
>
>Heres a listing of the files:
>-rwxr-xr-x   1 buhr     3g           250 Sep 27 08:32 program1
>-rwxr-xr-x   1 buhr     3g           196 Sep 27 08:32 program2
>-rw-r--r--   1 buhr     3g          8192 Sep 27 08:28 test
>
>
>If anyone can let me know what I'm doing wrong I'd appreciate it.

What makes you think there's no data in test?  The code runs fine
for me.

Oh, and if all you want is numbered records (which you simulate
with a hash here), DB_File has the DB_RECNO option that does just
that:

  tie %h, "DB_File", "test", O_RDWR|O_CREAT, 0644, $DB_RECNO or
    die "Can't create DB_File test: $!\n";

Anno

Anno


------------------------------

Date: 28 Sep 1999 11:31:56 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: DB_File
Message-Id: <37f0991c_1@newsread3.dircon.co.uk>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Joe Buhr  <joe.buhr@motorola.com> wrote in comp.lang.perl.misc:
>>I think this should be a simple problem...  hopefully someon can point
>>out my err right away, so here goes.
>>
>>I would like to use the perl DB_File module to store some data.  I'll
>>show what I'm trying to do in to seperate scripts.  Here's the syntax:
>>
>>************************************
>>#!/usr/misc/bin/perl
> 
> No -w.  No use strict.  Bat practice.
> 

Maybe thats what's wrong with English cricket team ... ;-}

/J\
-- 
"Pat was wondering if he could put his massive tool in my box" - Mrs
Doyle, Father Ted


------------------------------

Date: Tue, 28 Sep 1999 12:48:21 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: Getting record as hash
Message-Id: <37F09CF5.A8DDFFF0@gmx.net>

Graham Ashton wrote:
> 
> while (my %row_hash = $sth->fetchrow_hash) {

Where'd you get that from? fetchrow_hash is not a standard DBI
statement-handle method. fetchrow_array, yes. fetchrow_hashref, yes.
fetchrow_hash, no. So he'd need to do

  while(my $row_hash = $sth->fetchrow_hashref) { ... }

and then dereference à la $row_hash->{id}.

> P.S. I've not tested any of that either,

I noticed.

Cheers,
Philip


------------------------------

Date: Tue, 28 Sep 1999 11:11:29 GMT
From: BernhardMuenzer@cs.com (Bernhard Muenzer)
Subject: Re: HTML to ASCII
Message-Id: <7sq94m$hld$1@ssauraac-i-1.production.compuserve.com>

abigail@delanet.com wrote:
>Bernhard Muenzer (BernhardMuenzer@cs.com) wrote:
>`` This gets a problem when the original HTML code is broken; especially when 
>`` <TD> or <TR> tags aren't properly closed or nested.
>Eh? From the HTML DTD:
>    <!ELEMENT TR       - O (TH|TD)+    -- table row -->
>    <!ELEMENT (TH|TD)  - O (%flow;)*   -- table header cell, table data cell-->

The problem in this case were not <TD> and <TR> tags that were opened but not 
closed - in fact  they were closed, but not properly. The opening and closing 
tags were just scattered all over the document. The pages looked ok in IE (and 
lynx ;-), but nsgmls would complain bitterly, and Netscape refused to show 
anything but an ad banner.

That's why I had to resort to such desperate measures.

>Let's shoot people who don't RTFDTD.

I actually write DTDs, but usually I leave the job of reading them to tools 
like nsgmls. So shoot me...

-- 
/* Gesetzestext gesucht? http://www.compuserve.de/recht/gesetze/ */
int m,u,e=0;float l,_,I;main(){for(;1840-e;putchar((++e>907&&942>e?
61-m:u)["\n)moc.isc@rezneumb(rezneuM drahnreB"]))for(u=_=l=0;79-(m=
e%80)&&I*l+_*_<6&&26-++u;_=2*l*_+e/80*.09-1,l=I)I=l*l-_*_-2+m/27.;}


------------------------------

Date: Tue, 28 Sep 1999 11:17:09 +0100
From: "Daniel Vesma" <daniel@vesma.co.uk>
Subject: I can't see the error (short bit of code)
Message-Id: <7sq4ao$h0i$1@gxsn.com>

Hi,

I've been looking at this code for ages, and I can't see what's wrong with
it.

   $ShopID = param("ShopID") . "rem";
   $Filename = param("Filename");
   open(Products, "products.txt");

   while(<Products>)
   {
      $data = $data . $_;
    }

    close(Products);

    $data =~ s/$ShopID/$Filename/g;

    open(Products, ">products.txt");
    print Products $data;
    close(Products);

It should open products.txt replace every instance of $ShopID (including the
"rem") and replace it with $Filename. $ShopID is a string of numbers passed
from the user, and filename is also provided by the user.

The problem is, it doesn't appear to do anything. The file is not changed.
Any idea why?

Thanks guys.

Daniel Vesma - The Web Tree
 http://www.thewebtree.com




------------------------------

Date: 28 Sep 1999 10:23:51 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: I can't see the error (short bit of code)
Message-Id: <slrn7v15pn.a43.sholden@pgrad.cs.usyd.edu.au>

On Tue, 28 Sep 1999 11:17:09 +0100, Daniel Vesma <daniel@vesma.co.uk> wrote:
>Hi,
>
>I've been looking at this code for ages, and I can't see what's wrong with
>it.
>
>   $ShopID = param("ShopID") . "rem";
>   $Filename = param("Filename");
>   open(Products, "products.txt");

What happens if the file can't be opened... maybe checking return values
would be useful...

>
>   while(<Products>)
>   {
>      $data = $data . $_;
>    }

That's a very round about way of doing this... There are much easier
ways, the perl documentation mentions them. I recommend you read it.

>
>    close(Products);
>
>    $data =~ s/$ShopID/$Filename/g;
>
>    open(Products, ">products.txt");

Again, what happens if the gil can't be opened... maybe checking return
values would be really useful. Maybe including $! in the output if an error
occurs would be useful...

>    print Products $data;
>    close(Products);

What happens if the close fails...

>
>It should open products.txt replace every instance of $ShopID (including the
>"rem") and replace it with $Filename. $ShopID is a string of numbers passed
>from the user, and filename is also provided by the user.
>
>The problem is, it doesn't appear to do anything. The file is not changed.
>Any idea why?

You'll have more luck actually letting perl tell you what went wrong.


-- 
Sam

We prefer English to remain a rich language, quirky, sloppy, and full
of redundancy. Same for Perl. 
	--Larry Wall



------------------------------

Date: Tue, 28 Sep 1999 13:57:48 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Randomize array.....
Message-Id: <37F0AD3C.F913394B@ife.ee.ethz.ch>

Samuel Kilchenmann wrote:

> Ok, but isn't there a fundamental problem that the number of possible
> permutations grows so fast, that typical pseudo-random generators
> (which - as far as i know - have all an upper limit of possible
> pseudo-random sequences) will select a particular shuffle with - lets
> say - equal probability?
> 
> How is Perl's rand() seeded? If it uses a 32-bit seed value, then i
> assume that the shuffling of arrays with more than a few elements will
> not be very random. Is this a wrong assumption?

You are correct. I will propose an addition to the faq.
To the math:
The number of possible permutations of an array with m elements is m!
As an approximation, let's look at m=2^n
         __          __
         \           \
lb(m!) = /_ lb i  >  /_ j*2^j  > (n-1)*2^(n-1)
        i <= m      j < n

so the number of permutations for an array with 2^(k+1) values will
surely be greater than 2^(k*2^k).
For k=7, which is 256 elements, the number of possible permutations is
256! > 2^896
A random seed with more than 900 bits would be needed to get all
possible permutations with similar probablity.

To get an upper bound, I'll say

lb(m!) < lb(m^m) = m*lb(m) = n*2^n

So for the example, the upper bound is 2048 bits
To be safe, we need a seed of 2k bits to get an equal shuffle of a 256
element array using pseudo random numbers *REGARDLESS OF METHOD*

- Alex

PS The Swiss are out in force ;-)


------------------------------

Date: 28 Sep 1999 12:01:21 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex == Turing? (was remove the html tag in the file)
Message-Id: <7sqamh$7jm$1@lublin.zrz.tu-berlin.de>

Kenneth Bandes  <kbandes@home.com> wrote in comp.lang.perl.misc:
>"Randal L. Schwartz" wrote:
>> 
>> >>>>> "Dan" == Dan Sugalski <dan@tuatha.sidhe.org> writes:
>> 
>> Dan> That'd be kinda tough at this point. Perl's regexes are Turing-complete,
>> Dan> after all. (Anyone care to rewrite GCC as a regex? :)
>> 
>> I'm beginning to think that a "YACC-to-Perl" translator could possibly
>> rewrite the entire YACC grammar and associated actions as a *single*
>> regex using either 5.5 or perhaps 5.6 Perl.  The embedded (?{ ... })
>> blocks would allow the actions.
>
>Is this true?  Standard regular expressions (an alphabet together
>with concatenation, alternation, and repetition) are definitely
>not Turing-complete.  I.e. the set of languages described by
>regular expressions are a proper subset of the languages
>described by context-free grammars.
>
>For example, this grammer:
><exp> ::= "x" | "(" <exp> ")"
>i.e., the strings "x", "(x)", "((x))", etc.,

[...]

Well, backreferences (\1 and friends) make it possible to match things
that regular grammars don't.  A popular example is

  <exp> := "x" | "y" <exp> "y"

that is a "y" preceded and followed by like numbers of "x"s.  This
is not a regular expression in the strict sense, yet it is trivially
matched by Perl's m/(x*)y\1/.

Backreferences are a powerful tool.  TomC notes in the _Cookbook_
(p. 196) that they can be used to solve Diophantine equations of
order one.  A simpler example can be found in one of Abigail's sigs,
the one that prints primes.

Anno


------------------------------

Date: Tue, 28 Sep 1999 09:19:13 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: remove the html tag in the file
Message-Id: <lK%H3.19563$m4.77238483@news.magma.ca>

Earl Hood <ehood@medusa.acs.uci.edu> wrote in:
news:7sh9gr$5lc@news.service.uci.edu...
> In article <EVRG3.18678$m4.75164111@news.magma.ca>,
> Samuel Kilchenmann <skilchen@swissonline.ch> wrote:
>
[pointer to REBOL and example which was not good enough to convice
anybody]
>
> Does it properly handle
>
>     <IMG SRC="goo.fig" ALT="This is > than that">
>
> Or comment declarations?
>
No, but the regexp in perlfaq9 does neither.
So what Perl has to offer:
TOMC's striphtml (which may be good enough for most purposes, but which
does not handle nested comments (are they illegal?))

HTML::Parser which is unusable for newbies without a working example
which should be urgently added to perlfaq9.
(and it doesn't handle nested comments either, but they may be indeed
illegal in HTML)
I use something like:
use HTML::TokeParser;

my $html_file = $ARGV[0];

$p = HTML::TokeParser->new($html_file)
  or die "can't parse $html_file";

$p->{textify} = {};

while (my $token = $p->get_token()) {
    my $text = $p->get_text();
    print $text;
}

But none of them is able to handle script blocks which use string
literals containing HTML.

Maybe i should recommend to use the "Save as" function using "Textfile"
as the target file type which is available in some modern Webbrowsers,
or maybe "lynx -dump http://host.some.where/desired/page.htm"







------------------------------

Date: Tue, 28 Sep 1999 12:47:44 +0100
From: Paul Hand <Paul.Hand@document.co.uk>
Subject: t
Message-Id: <AA8133882F6DD311AAC2009027A2A3A703EDDD@PEGASUS>



> -----Original Message-----
> From:	Tom Phoenix [SMTP:rootbeer&pfaq*finding*@redcat.com]
> Posted At:	Tuesday, September 28, 1999 11:24 AM
> Posted To:	misc
> Conversation:	[Perl] How to find the Perl FAQ
> Subject:	[Perl] How to find the Perl FAQ
> 
> Archive-name: perl-faq/finding-perl-faq
> Posting-Frequency: weekly
> Last-modified: 18 Aug 1999
> 
> [ That "Last-modified:" date above refers to this document, not to the
> Perl FAQ itself! The last major update of the Perl FAQ was in Summer
> of
> 1998; of course, ongoing updates are made as needed. ]
> 
> For most people, this URL should be all you need in order to find
> Perl's
> Frequently Asked Questions (and answers).
> 
>     http://www.cpan.org/doc/FAQs/
> 
> Please look over (but never overlook!) the FAQ and related docs before
> posting anything to the comp.lang.perl.* family of newsgroups.
> 
> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
> 
> Beginning with Perl version 5.004, the Perl distribution itself
> includes
> the Perl FAQ. If everything is pro-Perl-y installed on your system,
> the
> FAQ will be stored alongside the rest of Perl's documentation, and one
> of these commands (or your local equivalents) should let you read the
> FAQ.
> 
>     perldoc perlfaq
>     man perlfaq
> 
> If a recent version of Perl is not properly installed on your system,
> you should ask your system administrator or local expert to help. If
> you
> find that a recent Perl distribution is lacking the FAQ or other
> important
> documentation, be sure to complain to that distribution's author.
> 
> If you have a web connection, the first and foremost source for all
> things
> Perl, including the FAQ, is the Comprehensive Perl Archive Network
> (CPAN).
> CPAN also includes the Perl source code, pre-compiled binaries for
> many
> platforms, and a large collection of freely usable modules, among its
> 560_986_526 bytes (give or take a little) of super-cool (give or take
> a little) Perl resources.
> 
>     http://www.cpan.org/
>     http://www.perl.com/CPAN/
>     http://www.cpan.org/doc/FAQs/FAQ/html/
>     http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
> 
> You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
> you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
> selected FTP sites is especially good for you, a full list of CPAN
> sites
> is in the SITES file within CPAN.)
> 
>     California     ftp://ftp.cdrom.com/pub/perl/CPAN/
>     Texas          ftp://ftp.metronet.com/pub/perl/
>     South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
>     Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
>     Australia      ftp://cpan.topend.com.au/pub/CPAN/
>     Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
>     Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
>     Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
> 
> If you have no connection to the Internet at all (so sad!) you may
> wish
> to purchase one of the commercial Perl distributions on CD-Rom or
> other
> media. Your local bookstore should be able to help you to find one.
> Another possibility is to use one of the FTP-via-email services; for
> more information on doing that, send mail to
> <mail-server@rtfm.mit.edu>
> (not to me!) with these lines in the body of the message, flush left:
> 
>     setdir usenet-by-group/news.announce.newusers
>     send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List
> 
> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
> 
> Comments and suggestions on the contents of this document
> are always welcome. Please send them to the author at
> <pfaq&finding*comments*@redcat.com>. Of course, comments on
> the docs and FAQs mentioned here should go to their respective
> maintainers.
> 
> Have fun with Perl!
> 
> -- 
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: 28 Sep 1999 12:02:28 +0200
From: lesve@geocities.com
Subject: Warning: Subroutine redefined (What to do ?)
Message-Id: <s5iu4vbbgr.fsf@ks.ericsson.se>


I'm using the CPAN library HTML::Parser;

In order to use the callback function start() I have the following
source code at the end of my perl file.

-----
#
# Callback fuctions
#

package HTML::Parser;

sub start
{
    my($tag, $attr, $attrseq, $origtext) = @_;
    # my statements
}
-----

The problem with this is that if I set the option -w (Warnings) so
will I always get the following Warning:

Subroutine start redefined at ...

My question is. Is there any possiblity to avoid just this Warning without
missing any other warnings. Maybe rewrite the code ?

 ----------==========ooooooooo<<<<<<<0>>>>>>>ooooooooo==========-----------
  Lennart Svensson \\ URL                         http://welcome.to/lesve |
  Karlstad, Sweden  \\ Password (valid 3 weeks) to spamfilter: <rekkhgro> |
  latitude 59.60 N   \\ PGP Key:       Send me email with Subject: PGPKEY |
  longitude 12.93 E   \\ e-mail:        oo0           lesve@geocities.com |
 --------------------------------------(   )--Ooo--------------------------
 My interest is in the future cause I'm \ (  (   )    No junk or spam mail
 gonna spend the rest of my life there   \_)  ) /
 ============================================(_/===========================
 The spamfilter password MUST be in the subject in replies. Sorry spam trap


------------------------------

Date: 28 Sep 1999 10:19:08 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Warning: Subroutine redefined (What to do ?)
Message-Id: <slrn7v15gs.a43.sholden@pgrad.cs.usyd.edu.au>

On 28 Sep 1999 12:02:28 +0200, lesve@geocities.com <lesve@geocities.com> wrote:
>
>I'm using the CPAN library HTML::Parser;
>
>In order to use the callback function start() I have the following
>source code at the end of my perl file.
>
>-----
>#
># Callback fuctions
>#
>
>package HTML::Parser;
>
>sub start
>{
>    my($tag, $attr, $attrseq, $origtext) = @_;
>    # my statements
>}
>-----
>
>The problem with this is that if I set the option -w (Warnings) so
>will I always get the following Warning:
>
>Subroutine start redefined at ...
>
>My question is. Is there any possiblity to avoid just this Warning without
>missing any other warnings. Maybe rewrite the code ?

Inherit from HTML::Parser and then write your own start sub in whatever
package you happen to create for you class.

I'm sure the documentation must give an example some where.



------------------------------

Date: 28 Sep 1999 11:30:56 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Warning: Subroutine redefined (What to do ?)
Message-Id: <37f098e0_1@newsread3.dircon.co.uk>

lesve@geocities.com wrote:
> 
> I'm using the CPAN library HTML::Parser;
> 
> In order to use the callback function start() I have the following
> source code at the end of my perl file.
> 
> -----
> #
> # Callback fuctions
> #
> 
> package HTML::Parser;
> 
> sub start
> {
>     my($tag, $attr, $attrseq, $origtext) = @_;
>     # my statements
> }
> -----
> 
> The problem with this is that if I set the option -w (Warnings) so
> will I always get the following Warning:
> 
> Subroutine start redefined at ...
> 
> My question is. Is there any possiblity to avoid just this Warning without
> missing any other warnings. Maybe rewrite the code ?

You are getting this error because you want to creating a new package
of your own - start() is already defined in HTML::Parser it just doesnt
do anything:

package Greengage;

use vars qw{@ISA};

require HTML::Parser;

@ISA = qw{HTML::Parser};

my $soft_fruit = Greengage->new ;

#
# etc ...

sub start
{
  ...
}


If you search this group on Deja.news you will find several examples of
the use of HTML::Parser.

/J\
-- 
"It's times like this I wish I had a penis" - Duckman


------------------------------

Date: Tue, 28 Sep 1999 13:28:31 +0200
From: Thomas Rassmann <rassmann@sdm.de>
Subject: Re: Warning: Subroutine redefined (What to do ?)
Message-Id: <37F0A65F.9CFABB3C@sdm.de>

Sam Holden wrote:
> 
> 
> I'm sure the documentation must give an example some where.

'perldoc perltoot' gives some examples and describes the whole
inheritance-stuff.

Tom
--
Thomas Rassmann			mailto:Thomas.Rassmann@sdm.de
sd&m AG				http://www.sdm.de
software design & management
Thomas-Dehler-Str. 27, D-81737 Muenchen, Germany
Tel +49 89 63812-346  Fax -410


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 928
*************************************


home help back first fref pref prev next nref lref last post