[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
[perl #51514] s/// on tied hashes
On Fri Mar 07 07:14:49 2008, mawic@gmx.de wrote:
> There seems to be a bug regarding tied hashes. If s/// is applied to
a
> string in such a hash, it either has no effect or Perl crashes. The
outcome
> is somewhat random, little changes in the code can completely change
the
> result. Minimal test case:
>
> -8<------------------------------------
> my $hr = { a => 'abc' };
> tie my %h, 'CaseInsHash', $hr;
> $h{A} =~ s/(.)/x$1x/g;
> print $h{A};
>
> package CaseInsHash;
> sub TIEHASH() { bless $_[1] }
> sub FETCH() { $_[0]->{lc($_[1])} }
> sub STORE() { $_[0]->{lc($_[1])} = $_[2] }
> -8<------------------------------------
That code doesn't segfault with me but
#!/usr/bin/perl -l
my $hr = { a => 'abc' };
tie my %h, 'CaseInsHash', $hr;
$h{A} =~ s/(.)/x$1x/g;
print $h{A};
package CaseInsHash;
sub TIEHASH() { bless $_[1] }
sub FETCH() { print "FETCH ($_[1])" if 0; $_[0]->{lc($_[1])} }
sub STORE() { print "STORE ($_[1] = $_[2])" if 0; $_[0]->{lc($_[1])} =
$_[2] }
__END__
does. (Which is essentially the same thing).
I couldn't get 5.8.8 to segfault, but 5.10.0 did segfault.
Trying the same code with maint (5.10.x - eventually 5.10.1) did not
segfault neither did perl-current (blead).
Both output:
xaxxbxxcx
Is it possible for you to build perl-current and test as well?
Kind regards,
Bram
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]