[26310] in Perl-Users-Digest
Perl-Users Digest, Issue: 8487 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 5 03:05:26 2005
Date: Wed, 5 Oct 2005 00: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)
Perl-Users Digest Wed, 5 Oct 2005 Volume: 10 Number: 8487
Today's topics:
regexp includes a dot in string <t18_pilot@hotmail.spam.com>
Re: regexp includes a dot in string <1usa@llenroc.ude.invalid>
Re: regexp includes a dot in string <tadmc@augustmail.com>
Re: threads, XSUB allocated memory, destructors, destru <tassilo.von.parseval@rwth-aachen.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 05 Oct 2005 02:42:35 GMT
From: "William Hymen" <t18_pilot@hotmail.spam.com>
Subject: regexp includes a dot in string
Message-Id: <v4H0f.8660$QE1.2124@newsread2.news.atl.earthlink.net>
All,
I would like to use a regular expression pattern
match to search for a string containing a dot
and not have it equivalent to a wildcard.
For example if $regexp='123.45';
$target =~ /$regexp/;
would normally match on
123.45
123x45
123g45 etc.
I would like only 123.45
Thanks in advance.
Bill
------------------------------
Date: Wed, 05 Oct 2005 02:57:13 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: regexp includes a dot in string
Message-Id: <Xns96E5E980B69FEasu1cornelledu@127.0.0.1>
"William Hymen" <t18_pilot@hotmail.spam.com> wrote in news:v4H0f.8660
$QE1.2124@newsread2.news.atl.earthlink.net:
> I would like to use a regular expression pattern
> match to search for a string containing a dot
> and not have it equivalent to a wildcard.
> For example if $regexp='123.45';
> $target =~ /$regexp/;
> would normally match on
> 123.45
> 123x45
> 123g45 etc.
>
> I would like only 123.45
You are supposed to check the FAQ *before* posting a question:
perldoc -q quote
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Tue, 4 Oct 2005 22:13:27 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regexp includes a dot in string
Message-Id: <slrndk6h6n.pag.tadmc@magna.augustmail.com>
William Hymen <t18_pilot@hotmail.spam.com> wrote:
> a string containing a dot
> and not have it equivalent to a wildcard.
> For example if $regexp='123.45';
$regexp='123\.45';
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 5 Oct 2005 07:36:54 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: threads, XSUB allocated memory, destructors, destruction
Message-Id: <slrndk6pjm.rs.tassilo.von.parseval@localhost.localdomain>
Also sprach Sisyphus:
><xhoster@gmail.com> wrote in message
>>
>> Could it be that Win32 is also trying to destroy everything twice, and it
>> is the destroying of the very first object, but on the second pass, which
>> produces the error? (doing so before the message on that one can be
>> printed)
>>
>
> Perhaps something along those lines is occurring. I've now found that
> whenever the script runs without error, the number of times that DESTROY()
> gets called is exactly double the number of times it ought to get called. So
> the doubling up is definitely happening.
>
> It's just that whenever it segfaults, the printout on the screen indicates
> that it's happening on the last object of the array. ie - if there's only
> one array involved (simplest scenario), containing x pointer objects, the
> segfault apparently occurs the xth time that DESTROY() is called. If it
> doesn't segfault at that point, then DESTROY() will be successfully called
> 2x times.
>
>> I tried moving the DESTROY from XSUB to Perl, and have the Perl DESTROY
>> call _destroy. But now DESTROY is getting called twice again, and we are
>> back to seg-faulting.
>>
>
> Heh - I'd tried that, too. Didn't help *me*, either :-)
Admiring all your attempts to understand and fix the problem, the
explanation for that behaviour is a different one.
When creating a new thread, data aren't shared by default. Instead, each
thread gets a clone. Perl can easily create clones of pure-Perl types
however it's out of its wits when a Perl type actually refers to an
outside resource (such as those allocated integers you were dealing
with).
So what happens is that the pure-Perl part is still cloned, but not the
underlying integer objects. Each of these cloned objects refer to the
same memory allocations. So for each clone DESTROY is called, trying to
deallocate the integer-objects. No wonder this results in double-,
triple-, etc.-frees, depending on how many threads you have.
So in essence: the XS portion of your code isn't thread-safe. In order
to make it thread-safe, you have to take control over the cloning
process. See 'perldoc perlmod' and search for "CLONE". For recent perls
(>= 5.8.7) all you have to do is provide a CLONE_SKIP method for the
package 'Experimental' (in your case). If it returns a true value, no
cloning of these object happens and therefore no multiple frees either.
Older perls only have a CLONE method that is called once for each
thread. It's not clear to me how it can be used to prevent cloning. I
think it can't and that's why CLONE_SKIP was introduced.
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
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 8487
***************************************