[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

perl 'read only' situation -- bizarre!



i noticed my HTML::Mason code, after upgrading from potato to
woody, started balking at a simple line of code:

	my @c = map {s/(.)/$1$1/g; $_} qw(fc0 066 ffc 600 cff 090 ccc 666 fc9 633 cff 096 c9c 090);

now, under potato, there was no problem. with woody, i've got

	"Modification of a read-only value attempted"

so i managed to track it down by playing with perl directly
(whitespace added for clarity):

$ perl -de 1
<snip>
  DB<1> x map {               s/././g; $_} qw/yes no maybe/
Modification of a read-only value attempted at (eval 36)[/usr/share/perl/5.6.1/perl5db.pl:1521] line 2.
  DB<2> x map {$k = $_; $k =~ s/././g; $k} qw/yes no maybe/
0  '...'
1  '..'
2  '.....'

it'll let me modify $k, but not $_, inside the map code.
($] shows perl to be version 5.006001; and under apache-perl
it also appears to be 5.006001).

munging $_ is a common practice around these parts.  is this a
Bad Thing to do?

it was okay under potato's perl -- now in woody, suddenly we
can't modify "$_" inside a map code segment? argh!

"perldoc -f map" shows that $_ is set as an ALIAS to each
element in the list; so when it's a constant, it now *points*?
to the scalar constant? not a copy, as it was before,
apparently...

<grr>

i suppose i'll have to use a for loop, then. pooh.

-- 
I use Debian/GNU Linux version 3.0;
Linux server 2.2.17 #1 Sun Jun 25 09:24:41 EST 2000 i586 unknown
 
DEBIAN NEWBIE TIP #59 from Bob Proulx <bob@proulx.com>
:
Wanting to SYNCHRONIZE YOUR SYSTEM CLOCK periodically? If you
think your system clock gathers or loses a few extra seconds
each day, you're probably looking for "ntp" which queries
several "network time protocol" servers, and sets your system
clock accordingly.
	apt-get install ntp ntp-simple ntp-doc ntpdate
then browse /usr/share/doc/ntp-doc/html for info.

Also see http://newbieDoc.sourceForge.net/ ...



Reply to: