Subject: | Modification of a read-only value attempted at ./XML/EasyOBJ.pm line 214. |
A line in XML::EasyOBJ::DESTROY modifies a read-only value, causing the following error:
Modification of a read-only value attempted at ./XML/EasyOBJ.pm line 214.
The culprit is shown below:
sub DESTROY {
local $^W = 0;
my $self = $_[0];
$_[0] = ''; # <=== this line is the culprit. Should not be done
unless ( $_[0] ) {
$_[0] = $self;
$AUTOLOAD = 'DESTROY';
return AUTOLOAD( @_ );
}
}
According to http://perldoc.perl.org/perlobj.html#Destructors
However, the $_[0] variable will be read-only in the destructor, so you cannot assign a value to it.
Encountered when using XML::EasyObj 1.12, perl v5.14.2, on Ubuntu Precise (14.04), Linux kernel 4.1.20