in reply to Re^2: Is there a way to lock arrays?
in thread Is there a way to lock arrays?
Sorry. I should have demonstrated that also.
use Internals qw[SetReadOnly];; @a = 1 .. 3;; SetReadOnly \@a;; print @a;; 1 2 3 $a[ 2] = 'changed';; print @a;; 1 2 changed push @a, 'added';; Modification of a read-only value attempted at SetReadOnly \$a[1];; $a[1] = 'changed';; Modification of a read-only value attempted at
|
|---|