Graham Barr wrote:
[...]
In your first statement
($self->{prog_name}= $0) =~ s|^.*/([^/]+)$|$1|;
you are calling s/// on the hash element. In the second
$self->{prog_name}= (my $_p= $0) =~ s|^.*/([^/]+)$|$1|;
you are just setting the hash element, actually to the value "1" not the prog
name.
oops ;)
Anyway, I suspect the issue is todo with calling s/// on the element of
a tied hash.
See if this reproduces the issue.
{
package Foo;
use Tie::Hash;
use base qw(Tie::StdHash);
sub new {
my $proto = shift;
my $inner = bless {};
my %outer;
tie %outer, __PACKAGE__, $inner;
bless \%outer;
}
}
$self = Foo->new;
($self->{prog_name} = $0) =~ s|^.*/([^/]+)$|$1|;
That's it: Same thing - the program is aborted with a stack trace!
(Btw: this is happening with glibc-2.7 on Debian "lenny")
So: what's the big difference between just assigning a value and calling s/// ?
Is there anything else that shouldn't be done on a tied hash?
Regards,
Peter