in reply to Modifying passed-in variables
Please remember to "use strict;" and "use warnings;". I reproduced the error "Modification of a read-only value" based on the incomplete code fragments you provided by commenting out "use strict;". Once you apply strict you get a more informative message that might have avoided this post.
use strict; use warnings; my $d = 3; sub foo { my ($data) = @_; $$data++; } eval {foo($d);}; print $@; # prints informative message provided by strict foo(\$d); print "$d\n"; __END__ Can't use string ("3") as a SCALAR ref while "strict refs" in use ... 4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Modifying passed-in variables
by mike65535 (Novice) on Nov 03, 2015 at 13:50 UTC | |
by Preceptor (Deacon) on Nov 03, 2015 at 14:49 UTC | |
by AnomalousMonk (Archbishop) on Nov 03, 2015 at 17:56 UTC |