This is new, isn't it? Oh, well, here it is again. -------- Original Message -------- Subject: failure notice Date: 31 Mar 2001 05:09:26 -0000 From: MAILER-DAEMON@tmtowtdi.perl.org To: rick.delaney@home.com Hi. This is the qmail-send program at tmtowtdi.perl.org. I'm afraid I wasn't able to deliver your message to the following addresses. This is a permanent error; I've given up. Sorry it didn't work out. <perl5-porters@perl.org>: This mailinglist does not accept postings crossposted to newsgroups - Contact list-owner@perl.org for help --- Below this line is a copy of the message. Return-Path: <rick.delaney@home.com> Received: (qmail 23855 invoked from network); 31 Mar 2001 05:09:25 -0000 Received: from femail1.rdc1.on.home.com (24.2.9.88) by tmtowtdi.perl.org with SMTP; 31 Mar 2001 05:09:25 -0000 Received: from home.com ([24.114.70.197]) by femail1.rdc1.on.home.com (InterMail vM.4.01.03.20 201-229-121-120-20010223) with ESMTP id <20010331050750.UGZE20157.femail1.rdc1.on.home.com@home.com> for <perl5-porters@perl.org>; Fri, 30 Mar 2001 21:07:50 -0800 Sender: rick Message-ID: <3AC569BB.49AAC734@home.com> Date: Sat, 31 Mar 2001 00:23:07 -0500 From: Rick Delaney <rick.delaney@home.com> X-Mailer: Mozilla 4.72C-CCK-MCD Caldera Systems OpenLinux [en] (X11; U; Linux 2.2.14 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.perl.misc CC: perl5-porters@perl.org Subject: Summary: closures and //o (was Re: regex-qr// for search and replace) References: <985712399.15095.0.nnrp-01.c3ad6974@news.demon.co.uk> <q3j1ctoh4nqs7loj9lrfh6eo20ksmfbjuf@4ax.com> <3AC1644F.357045C9@home.com> <9uo8ctk0cn8nv4qcu08vvp8paqu902d87b@4ax.com> <3AC49A83.9D063CD8@home.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit [posted to clpmisc and cc'ed p5p] This is supposed to be a summary but it's kinda long. Bart Lateur wrote: > > sub regexsub { > my $re = shift; > return sub { > shift =~ /$re/o; > } > } > $sub[0] = regexsub('fo+'); > $sub[1] = regexsub('ba+r'); > > foreach (qw'foo baaar fooooo bar bbbbbbbbar') { > foreach my $i(0, 1) { > $sub[$i]->($_) and print "Match for '$_' with regex $i\n"; > } > } > --> > Match for 'foo' with regex 0 > Match for 'baaar' with regex 1 > Match for 'fooooo' with regex 0 > Match for 'bar' with regex 1 > Match for 'bbbbbbbbar' with regex 1 > > In pre-5.6.0, //o and closures don't work too well together. There, > you'd have to put the closure (the sub that gets returned by regexsub) > in an eval STRING construct. I wrote that I get Match for 'foo' with regex 0 Match for 'foo' with regex 1 Match for 'fooooo' with regex 0 Match for 'fooooo' with regex 1 with my copy of 5.6.0 (and up). Bart wrote: > Gee. It works properly in ActivePerl 5.6.0 Build 623 for > MSWin32-x86-multi-thread, ... > Could it be in the patches for multi-thread support? Yes! I recompiled my copy of perl-5.6.0 to include threads and it now exhibits the same behaviour as ActivePerl. I also downloaded and compiled ActivePerl without threads and it only gives me the /fo+/ matches. But... It appears that multi-thread support has actually broken /o which is the only reason it "works". $ perl -le 'for (qw/foo bar baz/) {print if /$_/o }' foo $ perl -v This is perl, v5.6.0 built for i686-linux ... $ as_perl -le 'for (qw/foo bar baz/) {print if /$_/o }' foo bar baz $ as_perl -v This is perl, v5.6.0 built for i686-linux-thread-multi (with 1 registered patch, see perl -V for more detail) ... When run under -Mre=debug you can see that the regexp is compiled 3 times with threads but only once without. Maybe this is to be expected? Also see bug ID 20000810.008 and http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-08/msg00770.html -- Rick Delaney rick.delaney@home.comThread Next