Jonathan has asked for the wisdom of the Perl Monks concerning the following question:
That works as I wanted so I ported the code into my main program....#!/usr/local/bin/perl -w use strict; my $x = ['1','2',undef,undef,undef,'4']; @$x = map { $_ ||= "" } @$x; while (@$x) { print ">", shift @$x, "<\n"; } ### This gives >1< >2< >< >< >< >4<
This bombs instead with..$res = $dh->prepare($sql); $res->execute(); my @dataset = (); # Iterate over result set building up the result set do { while (my $data = $res->fetch()) { if ($res->{syb_result_type} == CS_ROW_RESULT) { if (defined $data) { @$data = map {$_ ||= ""} @$data;
I'm missing something simple here.. Help!Modification of a read-only value attempted at TradeExtract.pl line 10 +3 (#1) (F) You tried, directly or indirectly, to change the value of a constant. You didn't, of course, try "2 = 1", because the compile +r catches that. But an easy way to do the same thing is: sub mod { $_[0] = 1 } mod(2); Another way is to assign to a substr() that's off the end of the s +tring. Uncaught exception from user code: Modification of a read-only value attempted at TradeExtract.pl lin +e 103.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Modification of a read-only
by tye (Sage) on Sep 11, 2001 at 21:05 UTC | |
|
Re: Modification of a read-only
by derby (Abbot) on Sep 11, 2001 at 23:13 UTC | |
by mpeppler (Vicar) on Oct 09, 2001 at 01:15 UTC | |
by Jonathan (Curate) on Sep 12, 2001 at 11:18 UTC | |
by mpeppler (Vicar) on Oct 09, 2001 at 01:03 UTC |