[comp.lang.perl] panic: A_LVAL

piet@cs.ruu.nl (Piet van Oostrum) (03/14/90)

The following perl script crashes with a 'panic: A_LVAL':

$#x = 5;
for (@x) { $_ = '' ;}
-- 
Piet* van Oostrum, Dept of Computer Science, Utrecht University,
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31-30-531806   Uucp:   uunet!mcsun!ruuinf!piet
Telefax:   +31-30-513791   Internet:  piet@cs.ruu.nl   (*`Pete')

tneff@bfmny0.UU.NET (Tom Neff) (03/15/90)

In article <2645@ruuinf.cs.ruu.nl> piet@cs.ruu.nl (Piet van Oostrum) writes:
>The following perl script crashes with a 'panic: A_LVAL':
>
>$#x = 5;
>for (@x) { $_ = '' ;}

Same on my Sys V/386 PL14 version.  And

	$#x = 5;
	for (@x) { $_; }

dumps core.  Sounds worth fixing, and I can't find a quick workaround.
I suppose you could pre-initialize arrays by saying

	eval "@x = (" . "''," x $MAXELTS . ")";

instead of just bumping the index, until Larry fixes it.
-- 
"The country couldn't run without Prohibition.       ][  Tom Neff
 That is the industrial fact." -- Henry Ford, 1929   ][  tneff@bfmny0.UU.NET

tchrist@convex.com (Tom Christiansen) (10/05/90)

The following two-liner triggers a "panic: A_LVAL" abort out of perl
at patchlevel 18:

    for (1..10) { $a[$_] = 1;  } 
    for (@a)    { $_     = !$_; }

If the subscripts are changed to (0..10), it's just fine.

--tom
--
 "UNIX was never designed to keep people from doing stupid things, because 
  that policy would also keep them from doing clever things." [Doug Gwyn]

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (10/08/90)

In article <106865@convex.convex.com> tchrist@convex.Com (Tom Christiansen) writes:
: The following two-liner triggers a "panic: A_LVAL" abort out of perl
: at patchlevel 18:
: 
:     for (1..10) { $a[$_] = 1;  } 
:     for (@a)    { $_     = !$_; }
: 
: If the subscripts are changed to (0..10), it's just fine.

I just fixed that one last week.  When "foreach" iterates over an array,
it now creates any missing values so that they can be assigned to.

Larry