D
David Squire
Peter said:So there is an even simpler (Look Ma! No TreeBuilder!) script to test
this:
----- test_without_TreeBuilder ---------------------------------
#!/usr/local/bin/perl
use strict;
use warnings;
my $str = 'Yahoo! U.S. News';
utf8::upgrade($str);
dumpstr($str);
($str =~ /(.*)news/i) or warn "No match!\n";
my $testPart = $1;
my $testWhole = $&;
my $breakpoint = 3;
print "testPart: <$testPart>, testWhole: <$testWhole>\n";
sub dumpstr {
my ($s) = @_;
print utf8::is_utf8($s) ? "char" : "byte", " string: ";
for (split(//, $s)) {
printf("%#x %s ", ord($_), /[[rint:]]/ ? $_ : '.');
}
print "\n";
}
Interesting. This gives different, but still unexpected behaviour for me
when run under the debugger (no problems when run with out it):
---- Start transcript ----
~/tmp (davids : dms54)
Aug 27 - 17:26 % perl -d test_without_TreeBuilder.pl
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main:
6: my $str = 'Yahoo! U.S. News';
DB<1> n
main:
7: utf8::upgrade($str);
DB<1> n
main:
8: dumpstr($str);
DB<1> n
char string: 0x59 Y 0x61 a 0x68 h 0x6f o 0x6f o 0x21 ! 0x20
0x4e N 0x65 e 0x77 w 0x73 s 0x3a : 0x20 0x55 U 0x2e . 0x53 S
0x2e . 0x20 0x4e N 0x65 e 0x77 w 0x73 s
main:
9: ($str =~ /(.*)news/i) or warn "No match!\n";
DB<1> n
---- End transcript ----
It never returned from that state (well, not yet
for ~3 minutes). top shows that perl is running and taking up about
30-40% of my CPU, but is not growing in size.
I always have the DarwinPorts version of perl installed, which is:
----
~/tmp (davids : dms54)
Aug 27 - 17:30 % /opt/local/bin/perl -v
This is perl, v5.8.8 built for darwin-2level
----
With this version, there is no error running test_without_TreeBuilder.pl
under the debugger. The out-of-the-box Mac OS X perl is:
----
~/tmp (davids : dms54)
Aug 27 - 17:30 % perl -v
This is perl, v5.8.6 built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
----
So I guess this is a problem that either went away in 5.8.8, or is
related to multithreading.
DS