Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

sky (1411)

sky
  (email not shown publicly)

sky on IRC

Journal of sky (1411)

Friday May 25, 2001
09:16 AM

Regex joy or not?

[ #208 ]
Most defintly not!
Dan Sugalski correctly poined out that my test with match variables didn't proove anything, it boiled down to me missunderstanding how the match variables are scoped. So I whipped up another test that also seems to show (not proove) that regex match variables are not shared.

my $i = 1000000;
$foo = "bar";
push @threads, IThread->create(sub { for (1..$i) { $foo =~/(.)/; print "error\n" if($1 ne 'b')}});
push @threads, IThread->create(sub { for (1..$i) { $foo =~/(.)/; print "error\n" if($1 ne 'b')}});
push @threads, IThread->create(sub { for (1..$i) { $foo =~/.(.)/; print "error\n" if($1 ne 'a')}});
push @threads, IThread->create(sub { for (1..$i) { $foo =~/.(.)/; print "error\n" if($1 ne 'a')}});
push @threads, IThread->create(sub { for (1..$i) { $foo =~/..(.)/; print "error\n" if($1 ne 'r')}});
push @threads, IThread->create(sub { for (1..$i) { $foo =~/..(.)/; print "error\n" if($1 ne 'r')}});

This does not give an error on my SINGLE cpu box. I am still waiting for somone with a multipel CPU box to try it out.

Artur