[32024] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3288 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 16 21:09:50 2011

Date: Wed, 16 Feb 2011 18:09:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 16 Feb 2011     Volume: 11 Number: 3288

Today's topics:
    Re: Hashes are good, but not good enough. <nospam.gravitalsun@hotmail.com.nospam>
    Re: Hashes are good, but not good enough. <tzz@lifelogs.com>
    Re: Regex question; match <br> after opening tag <rvtol+usenet@xs4all.nl>
    Re: Regex question; match <br> after opening tag <nospam.gravitalsun@hotmail.com.nospam>
    Re: Regex question; match <br> after opening tag <justin.1011@purestblue.com>
    Re: Regex question; match <br> after opening tag <jwcarlton@gmail.com>
    Re: Regex question; match <br> after opening tag <jwcarlton@gmail.com>
    Re: Regex question; match <br> after opening tag <jurgenex@hotmail.com>
    Re: Regex question; match <br> after opening tag <sherm.pendley@gmail.com>
    Re: Regex question; match <br> after opening tag <sherm.pendley@gmail.com>
    Re: Regex question; match <br> after opening tag <nospam.gravitalsun@hotmail.com.nospam>
    Re: Regex question; match <br> after opening tag <sherm.pendley@gmail.com>
    Re: Regex question; match <br> after opening tag <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Regex question; match <br> after opening tag <jwcarlton@gmail.com>
    Re: Regex question; match <br> after opening tag <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Regex question; match <br> after opening tag <sherm.pendley@gmail.com>
    Re: repository problem w/x64 ActivePerl 5.12 <jl_post@hotmail.com>
    Re: Subroutine exec redefined warning with perl 5.12.2 <marc.girod@gmail.com>
    Re: Subroutine exec redefined warning with perl 5.12.2 <marc.girod@gmail.com>
    Re: Subroutine exec redefined warning with perl 5.12.2 <marc.girod@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 16 Feb 2011 10:18:05 +0200
From: "George Mpouras" <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: Hashes are good, but not good enough.
Message-Id: <ijg16n$31d8$1@ulysses.noc.ntua.gr>


>
> Which database can efficently serve hundreds of millions of records
> without (excessive) disk access with 200bytes of memory/per/record
> footprint?
>
> Ilya

How about google ;
Have you every think the data size of google and how is it possible to get 
instant results ;
As far I can undestand google is using perfect hashes over inverted files. 




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

Date: Wed, 16 Feb 2011 08:36:47 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Hashes are good, but not good enough.
Message-Id: <87d3ms6o74.fsf@lifelogs.com>

On Wed, 16 Feb 2011 03:47:05 +0000 (UTC) Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote: 

IZ> On 2011-02-14, Ted Zlatanov <tzz@lifelogs.com> wrote:
>> Hundreds of millions of hash keys will take up a lot of memory, probably
>> unnecessarily.

IZ> What makes this "probable"?  Possibly, it is "possible", but we saw no
IZ> indication which would support your conjecture...

I'm still waiting for an actual use case.  Theoretically anything is useful.

>> Iterating through them will be painful even unsorted (as with any
>> large amount of data, it's the management that's hard, not
>> accumulating it).

IZ> It will be much less painful with a hash than with any other tool I
IZ> know.  What do you have in mind?

I'm talking about hundreds of millions of iterations in a tight loop.
My point was that throwing that much data in one place makes it hard to
manage, not that hashes in particular are bad at key iteration.

>> I would *at least* partition the keys with a multi-level hash.

IZ> Do not see how this would change anything...

It depends on the use case.  For example, if each key can be mapped to a
date and all use cases only need one day at a time, it would make sense
to partition by day.  Anyhow, my whole point is "think before you throw
a lot of data in a single place."  It may indeed make sense to create
such a large single-level hash.  I'm not aware of such a case but am
willing to hear specifics and discuss them.

On Wed, 16 Feb 2011 03:53:07 +0000 (UTC) Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote: 

IZ> On 2011-02-15, Ted Zlatanov <tzz@lifelogs.com> wrote:
>> (AKA "put it in a database", and of course databases are *engineered* to
>> store and index large amounts of data)

IZ> So are Perl hashes - and I expect they are going to be order(s?) of
IZ> magnitude more space efficient and quickier than databases.  (Provided
IZ> that memory holds enough water.)

You have to at least consider the cost of memory.  It's significantly
more expensive than disk and requires a much larger startup time to
populate after a restart.

IZ> Which database can efficently serve hundreds of millions of records
IZ> without (excessive) disk access with 200bytes of memory/per/record
IZ> footprint?

You can do it from a file easily enough, if the records are fixed-size.

Indeed, if the pattern is to constantly iterate unsorted and to always
append new records, a file with fixed-size records would make a lot of
sense.  The hash key lookup becomes a lookup in a file offset index.
Deletions can be implemented with tombstone markers that are removed
during compaction.  Such a scheme works pretty well for the Cassandra
database (although they serialize objects instead of using fixed-size
records).

On Wed, 16 Feb 2011 10:18:05 +0200 "George Mpouras" <nospam.gravitalsun@hotmail.com.nospam> wrote: 

GM> How about google ; Have you every think the data size of google and
GM> how is it possible to get instant results ; As far I can undestand
GM> google is using perfect hashes over inverted files.

Google uses (at least until recently) BigTable, whose concepts are also
seen in Cassandra and other NoSQL databases.  They also have custom
filesystems, well-tuned algorithms (map/reduce, heavy use of bloom
filters), hordes of engineers, and tons of hardware.

Their Guava Java libraries are an interesting view into Google's
internal data modeling.  The MapMaker class in particular is very
educational.  I often wish Perl 5 had something so clean, especially in
regards to concurrency.

Ted


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

Date: Wed, 16 Feb 2011 09:26:43 +0100
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <4d5b8a43$0$41117$e4fe514c@news.xs4all.nl>

On 2011-02-16 06:18, jwcarlton wrote:
> On Feb 16, 12:11 am, Tad McClellan<ta...@seesig.invalid>  wrote:
>> jwcarlton<jwcarl...@gmail.com>  wrote:

>>> I'm trying to remove opening and closing<br>  tags.
>>
>> There is no such thing as a "closing"<br>  tag...
>>  [...]
>
> Seriously, why even both replying?

I guess because all answers to your questions are in the FAQ.
That you shouldn't quote sigs is in another one.

-- 
Ruud


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

Date: Wed, 16 Feb 2011 11:03:15 +0200
From: "George Mpouras" <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <ijg3rf$9f2$1@ulysses.noc.ntua.gr>

my $text = '<div class=whatever><span
class=whatever><font class=whatever><br>help<o><br><br>Hello, 
World!<br><br></font></span>
</div>';

while ( $text =~/<br>(.+?)<br>/gm )
{
(my $a = $^N)=~s/<.+?>//g;
print "*$a*\n";
}




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

Date: Wed, 16 Feb 2011 09:19:23 +0000
From: Justin C <justin.1011@purestblue.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <rdhs28-k0c.ln1@zem.masonsmusic.co.uk>

On 2011-02-16, jwcarlton <jwcarlton@gmail.com> wrote:
>
> Seriously, why even both replying?

Then show us a sample of the content that you are receiving so we can
better understand the problem. Antagonising those who offer suggestions
is never a good move. 

   Justin.

-- 
Justin C, by the sea.


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

Date: Wed, 16 Feb 2011 02:40:45 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <86e69b9c-75aa-4e40-9a0f-ed11c9910c1f@z20g2000yqe.googlegroups.com>

> > Seriously, why even both replying?
>
> Then show us a sample of the content that you are receiving so we can
> better understand the problem. Antagonising those who offer suggestions
> is never a good move.

Justin, please understand that Tad was giving a PITA answer, not a
suggestion. I definitely wasn't antagonizing; if you look closely at
his response, you'll see what I mean.

He and I have a history, and in the years that I've been watching, I
don't think he's ever given a REAL answer to anyone.

Anyway, let's not let Tad ruin yet another thread.

I gave a sample of what I get in the OP:

<div class=whatever><span class=whatever><font
class=whatever><br><br><br>Hello, World!<br><br></font></span></div>

I'm trying to write a regex that will remove <br> from both the
beginning and the end of the string, but that's also nested within
other tags.

I already use this, which obviously removes the <br> when it's not
nested inside of other tags:

$text =~ s/^(<br>)+|(<br>)+$//gi;

I gave code samples in my OP, too, of what I think will work; the only
problem is that it requires the tags to be in that order; DIV, then
SPAN, then FONT. If the FONT comes before the SPAN, then it doesn't
work, so I'm trying to create a more streamline method.

Thanks, Justin.


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

Date: Wed, 16 Feb 2011 02:45:06 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <76c492c3-46b5-47ea-ad2c-02d58c4e4288@w7g2000pre.googlegroups.com>

On Feb 16, 4:03=A0am, "George Mpouras"
<nospam.gravital...@hotmail.com.nospam> wrote:
> my $text =3D '<div class=3Dwhatever><span
> class=3Dwhatever><font class=3Dwhatever><br>help<o><br><br>Hello,
> World!<br><br></font></span>
> </div>';
>
> while ( $text =3D~/<br>(.+?)<br>/gm )
> {
> (my $a =3D $^N)=3D~s/<.+?>//g;
> print "*$a*\n";
> }
>
>

Awesome, George! I really appreciate that.


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

Date: Wed, 16 Feb 2011 05:38:12 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <96knl6p2lqgconu2k7d9ccdrai26mt5ivm@4ax.com>

jwcarlton <jwcarlton@gmail.com> wrote:
>I gave a sample of what I get in the OP:
>
><div class=whatever><span class=whatever><font
>class=whatever><br><br><br>Hello, World!<br><br></font></span></div>
>
>I'm trying to write a regex that will remove <br> from both the
>beginning and the end of the string, but that's also nested within
>other tags.
>
>I already use this, which obviously removes the <br> when it's not
>nested inside of other tags:
>
>$text =~ s/^(<br>)+|(<br>)+$//gi;
>
>I gave code samples in my OP, too, of what I think will work; the only
>problem is that it requires the tags to be in that order; DIV, then
>SPAN, then FONT. If the FONT comes before the SPAN, then it doesn't
>work, so I'm trying to create a more streamline method.

And these conditions are exactly why using a simple-minded regular
expression is an unsuitable approach, in particular if you have no
control over the format of the incoming data.
Use a parser that actually parses HTML fragments and creates a syntax
tree, and then delete or keep exactly those elements that you want. 

Doing it on the textual level is not going to work reliably. 

jue


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

Date: Wed, 16 Feb 2011 14:00:12 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <m2sjvn6c03.fsf@sherm.shermpendley.com>

jwcarlton <jwcarlton@gmail.com> writes:

> Seriously, why even both replying?

Why even bother asking, if you intend to debate and/or ignore every
answer you get?

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


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

Date: Wed, 16 Feb 2011 14:05:34 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <m2oc6b6br5.fsf@sherm.shermpendley.com>

jwcarlton <jwcarlton@gmail.com> writes:

> He and I have a history

Then maybe you should simply ignore his posts.

> I gave a sample of what I get in the OP:
>
> <div class=whatever><span class=whatever><font
> class=whatever><br><br><br>Hello, World!<br><br></font></span></div>
>
> I'm trying to write a regex that will remove <br> from both the
> beginning and the end of the string, but that's also nested within
> other tags.

Don't do that with a regex. A regular expression can only express a
regular grammar - hence the name. HTML is a context-free grammar, which
needs a more complex parser than a regex can provide.

Have a look at HTML::Parser:

    <http://search.cpan.org/perldoc?HTML::Parser>

And, if you're interested in learning more about the difference between
regular and context-free grammars, read about the Chomsky Hierarchy:

    <http://en.wikipedia.org/wiki/Chomsky_hierarchy>

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


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

Date: Thu, 17 Feb 2011 00:26:40 +0200
From: George Mpouras <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <ijhiv0$23sq$1@ulysses.noc.ntua.gr>

>
> Don't do that with a regex. A regular expression can only express a
> regular grammar - hence the name. HTML is a context-free grammar, which
> needs a more complex parser than a regex can provide.
>

sometimes a "good enough" workaround is just fine


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

Date: Wed, 16 Feb 2011 17:56:50 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <m2zkpv4mh9.fsf@sherm.shermpendley.com>

George Mpouras <nospam.gravitalsun@hotmail.com.nospam> writes:

> Sherm Pendley <sherm.pendley@gmail.com> writes:
>
>> Don't [parse HTML] with a regex. A regular expression can only express a
>> regular grammar - hence the name. HTML is a context-free grammar, which
>> needs a more complex parser than a regex can provide.
>
> sometimes a "good enough" workaround is just fine

Not if you're working for me... :-)

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


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

Date: Wed, 16 Feb 2011 15:34:01 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <9g3u28x7nu.ln2@goaway.wombat.san-francisco.ca.us>

On 2011-02-16, George Mpouras <nospam.gravitalsun@hotmail.com.nospam> wrote:
>>
>> Don't do that with a regex. A regular expression can only express a
>> regular grammar - hence the name. HTML is a context-free grammar, which
>> needs a more complex parser than a regex can provide.
>
> sometimes a "good enough" workaround is just fine

Perhaps.  This isn't one of those times, especially since the HTML
modules available with Perl are excellent and easy to use.

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: Wed, 16 Feb 2011 16:07:06 -0800 (PST)
From: jwcarlton <jwcarlton@gmail.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <cb75beab-d206-4ce4-8b58-06a4af368206@c10g2000vbv.googlegroups.com>

> > He and I have a history
>
> Then maybe you should simply ignore his posts.

I try; really, I do. I was mostly concerned that others would glance
over the thread and think that he had legitimately solved the problem.


> Don't do that with a regex. A regular expression can only express a
> regular grammar - hence the name. HTML is a context-free grammar, which
> needs a more complex parser than a regex can provide.
>
> Have a look at HTML::Parser:
>
> =A0 =A0 <http://search.cpan.org/perldoc?HTML::Parser>

For now, I have a filter that I wrote a few years ago, and it's
working well enough so I'm just trying to correct what's really just
one minor issue. I do intend to change it to work with a parser in the
near future, though; which would probably have been smarter in the
beginning, but when I asked for help, I only got responses like the
first few in this thread, so I just gave up and did it a way that I
knew.

In fact, I just looked, and the responses I got then were that I
should write my own. Funny when you consider that, now that I've
written my own, all of the responses are that I should have used a
module! LOL

I've considered HTML::Parser, but if I understand correctly, don't you
have to specifically define which tags you want to parse? That's all
well and good, except that people often paste data from other sites,
so it's difficult to think of every possibility.

I'm looking at HTML::HTML5::Parser, but I'm messing up in a way that I
don't get. Here's the code I'm entering, which is almost exactly
what's on CPAN:

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use HTML::HTML5::Parser;

$comment =3D "<!doctype html>\n<title>Foo</title>\n<p><b><i>Foo</b> bar</
i>.\n<p>Baz</br>Quux.";

my $parser =3D HTML::HTML5::Parser->new;
$comment =3D $parser->parse_string($comment);

print "Content-type: text/html\n\n";
print "$comment";
exit;

All this prints, though, is:

XML::LibXML::Document=3DSCALAR(0x924f988)

I double checked, and do have XML::LibXML installed. The
HTML::HTML5::Parser is a fresh install from yesterday.

Any suggestions on how to print the parsed string, if I'm doing it
incorrectly?


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

Date: Wed, 16 Feb 2011 16:23:15 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <jc6u28x2cv.ln2@goaway.wombat.san-francisco.ca.us>

On 2011-02-17, jwcarlton <jwcarlton@gmail.com> wrote:
>
> I've considered HTML::Parser, but if I understand correctly, don't you
> have to specifically define which tags you want to parse? That's all
> well and good, except that people often paste data from other sites,
> so it's difficult to think of every possibility.

HTML::Parser can do basically any HTML parsing.  But this also means
you have a fair amount of coding to tell it what to do.  You can also
look at HTML::TreeBuilder, which uses HTML::Parser to build a nice hash
structure and provide powerful search functions on the structure.

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: Wed, 16 Feb 2011 20:18:46 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Regex question; match <br> after opening tag
Message-Id: <m2r5b74fwp.fsf@sherm.shermpendley.com>

jwcarlton <jwcarlton@gmail.com> writes:

>> > He and I have a history
>>
>> Then maybe you should simply ignore his posts.
>
> I try; really, I do.

"Do, or do not - there is no try." - Yoda

>> Don't do that with a regex. A regular expression can only express a
>> regular grammar - hence the name. HTML is a context-free grammar, which
>> needs a more complex parser than a regex can provide.
>>
>> Have a look at HTML::Parser:
>>
>>     <http://search.cpan.org/perldoc?HTML::Parser>
>
> For now, I have a filter that I wrote a few years ago, and it's
> working well enough so I'm just trying to correct what's really just
> one minor issue. I do intend to change it to work with a parser in the
> near future, though; which would probably have been smarter in the
> beginning, but when I asked for help, I only got responses like the
> first few in this thread, so I just gave up and did it a way that I
> knew.
>
> In fact, I just looked, and the responses I got then were that I
> should write my own.

That just goes to show, you should consider the source. One of our more
persistent trolls here used to give that same, very misguided, advice
whenever the topic came up. I'm sorry to hear you were misled by bad
advice.

> I've considered HTML::Parser, but if I understand correctly, don't you
> have to specifically define which tags you want to parse? That's all
> well and good, except that people often paste data from other sites,
> so it's difficult to think of every possibility.

If you're trying to parse arbitrary HTML, then a parser (whether one from
CPAN, or one you write yourself) is a *must*. HTML is a context-free
grammar, which *cannot* be fully expressed in a regex. I lack the math
and comp-sci theory to fully understand (much less explain, LOL!) the
formal proof of this, but the proof does exist.

> I'm looking at HTML::HTML5::Parser, but I'm messing up in a way that I
> don't get. Here's the code I'm entering, which is almost exactly
> what's on CPAN:
>
> #!/usr/bin/perl
> use CGI::Carp qw(fatalsToBrowser);
> use HTML::HTML5::Parser;
>
> $comment = "<!doctype html>\n<title>Foo</title>\n<p><b><i>Foo</b> bar</
> i>.\n<p>Baz</br>Quux.";
> my $parser = HTML::HTML5::Parser->new;
> $comment = $parser->parse_string($comment);
>
> print "Content-type: text/html\n\n";
> print "$comment";
> exit;
>
> All this prints, though, is:
>
> XML::LibXML::Document=SCALAR(0x924f988)

This simply shows that $comment is an object; to get a string from it
that you can print, you need to call one of its methods.

> I double checked, and do have XML::LibXML installed. The
> HTML::HTML5::Parser is a fresh install from yesterday.

Good to know, but nothing about the above output suggests a missing or
outdated module. Quite the opposite - parse_string() is returning an
object of class XML::LibXML::Document, which implies that parse_string()
was successful, and that the module you need is installed and working.

> Any suggestions on how to print the parsed string, if I'm doing it
> incorrectly?

The HTML::HTML5::Parser docs say that parse_string() should give you an
instance of XML::LibXML::Document, and the message above indicates that
it did. That's good news, as it shows that nothing actually went wrong;
the problem is that you're trying to print the object as if it were just
a string. What you should do instead is check the docs for that module,
and find a method for that object that will give you a string. At first
glance, it looks to me like toString() would be appropriate:

  print $comment->toString();

Note that X::L::Document has some other interesting methods, that relate
to querying the document to get a collection of all the elements of a
given type, or an element with a particular id. These DOM methods are
the same (language differences aside) as those provided by JavaScript
on the document object.

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer


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

Date: Wed, 16 Feb 2011 16:44:07 -0800 (PST)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: repository problem w/x64 ActivePerl 5.12
Message-Id: <821af141-2719-4786-9950-4e05cdb738d2@x1g2000yqb.googlegroups.com>

On Feb 16, 12:09=A0pm, Jonathan Epstein <jae6...@gmail.com> wrote:
>
> I have used PPM and/or CPAN many times to install the ptkdb
> debugger, but this time am stuck. =A0I'm running a 64-bit version
> of Perl on Windows 7, and am trying to use the bribes.org
> repository.


   I had quite a few problems like yours whenever I installed a new
version of ActiveState Perl on a new version of Windows.  That pretty
much went away, however, when I switched to Strawberry Perl.

   Once I installed Strawberry Perl, I was able to use the ptkdb
debugger after installing it with these commands:

      cpan Tk
      cpan Devel::ptkdb

(Occasionally "cpan Devel::ptkdb" would fail, in which case I'd use
"ppm install Devel::ptkdb" instead.)

   Because of its ease of installing modules, I never regretted
switching to Strawberry Perl when using Windows.  And since many of my
peers still use ActivePerl, it's still pretty much hit-or-miss when
I'm trying to set them up to be able to use ptkdb.

   I hope this helps, Jonathan.

   Cheers,

   -- Jean-Luc


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

Date: Wed, 16 Feb 2011 03:40:22 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: Subroutine exec redefined warning with perl 5.12.2
Message-Id: <a7e27bcc-e9bc-4eca-9102-99bc94d63124@o13g2000yql.googlegroups.com>

On Feb 15, 10:00=A0pm, "C.DeRykus" <dery...@gmail.com> wrote:

> But AFAIK a "subroutine redefined..." occurs
> only if a sub is redefined within a class -
> not because there are sub's of the same name
> in its inheritance tree.

This is surprising: there is only one redefinition of exec per class.
There are two in the hierachy classes with similar names: Argv and
ClearCase::Argv (of course, it would be a bug if it affected,and it
doesn't seem to).

> The only workaround is mentioned here:
>
> perl -Mdiagnostics=3D-verbose -wlE

Excellent! Thanks!

> =A0 =A0 Subroutine x redefined at -e line 1 (#1)
> =A0 =A0 (W redefine) You redefined a subroutine.
> =A0 =A0 =A0To suppress this warning,
>
> =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 no warnings 'redefine';
> =A0 =A0 =A0 =A0 eval "sub name { ... }";
> =A0 =A0 =A0 =A0 }

Thanks. Very useful indeed.
I do get a similar output with my script:

Subroutine exec redefined at C:/strawberry/perl/site/lib/Argv.pm line
852 (#2)
    (W redefine) You redefined a subroutine.  To suppress this
warning, say

Now, this doesn't tell where #1 would be... (which I cannot find).
Thanks again.
I continue my investigations.

Marc


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

Date: Wed, 16 Feb 2011 03:52:12 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: Subroutine exec redefined warning with perl 5.12.2
Message-Id: <77642624-d750-4738-ab09-85175f7d5988@l11g2000yqb.googlegroups.com>

On Feb 16, 11:40=A0am, Marc Girod <marc.gi...@gmail.com> wrote:

> Now, this doesn't tell where #1 would be... (which I cannot find).

Sorry, I understand now that #1 was unrelated:

Name "main::rem" used only once: possible typo at
        c:\strawberry\perl\site\bin\cleartool.bat line 1 (#1)

A hack to get the Perl script run as a Windows batch.
But no clue about where the 'first definition' might be...

Marc


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

Date: Wed, 16 Feb 2011 04:23:53 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: Subroutine exec redefined warning with perl 5.12.2
Message-Id: <405950c7-1542-4be6-85c9-0ba6f8517e65@f18g2000yqd.googlegroups.com>

On Feb 16, 11:40=A0am, Marc Girod <marc.gi...@gmail.com> wrote:

> To suppress this warning, say

        {
        no warnings 'redefine';
        eval "sub name { ... }";
        }

Unfortunately, this is not very practical...
I used actually: eval qq(sub name { ... });
It results in a large batch of errors for all the variables used:

Variable "@cmd" is not imported at C:/strawberry/perl/site/lib/Argv.pm
line 854.
 ...

Putting: no warnings 'redefine';
at file scope is likely to be *very* counterproductive...

Marc


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 3288
***************************************


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