On Thu, 30 Jun 2005 at 15:51 +0200, Rafael Garcia-Suarez wrote:

David Dyck (via RT) wrote:

The following 3 line test program results in the same error when pushing 
__PACKAGE__
onto @ISA:
    our @ISA = qw(a b);
    push @ISA, 'main';
    push @ISA, __PACKAGE__;

"Modification of a read-only value attempted at isabug.pl line 3."

Renaming the @ISA variable makes the error message go away.

I can reproduce this with other magic variables as well :

   $ ./perl -e '%ENV = (PATH => __PACKAGE__)'
   Modification of a read-only value attempted at -e line 1.

Thanks for the patch.

Before I applied the patch, I tried another experiment
using B::Deparse and was surprised to see that
all 3 "push" lines deparse the same. If the line deparses the same, than why wast the
error message only issued for the "push @ISA, __PACKAGE__" line?
(it was also interesting to see that eval{}'ing the offending
line (not shown) is another work-around that still modifys @ISA
as desired.)

$ cat isabug.pl
our @ISA = qw(a b);
push @ISA, 'main';
push @ISA, __PACKAGE__.'';
push @ISA, __PACKAGE__;
print join("\t", @ISA),"\n";

$ perl -MO=Deparse isabug.pl
our(@ISA) = ('a', 'b');
push @ISA, 'main';
push @ISA, 'main';
push @ISA, 'main';
print join("\t", @ISA), "\n";
isabug.pl syntax OK

Reply via email to