kansas-city-pm-list  

RE: 5.8.0 changes file

Garrett Goebel
Thu, 10 Oct 2002 13:06:43 -0700

Title: RE: 5.8.0 changes file

From: david nicol [mailto:[EMAIL PROTECTED]]
> >
> >    for (1..5) { $_++ }
> >
> > works without complaint.  It shouldn't.
...
>
> Who says that modifying $_ here causes a problem?

1..5 are numeric literals. I would have expected an error like:

Can't modify constant item in postincrement (++) at ...
  or
Modification of a read-only value attempted at ...

as you get with:
  print 1++;
    and
  sub foo { print $_++ } foo(1);


I'd be interested to hear the rationalization from perl5-porters as to why it isn't a bug... if that is what their consensus is.

--
Garrett Goebel
IS Development Specialist

ScriptPro                   Direct: 913.403.5261
5828 Reeds Road               Main: 913.384.1008
Mission, KS 66202              Fax: 913.384.2180
www.scriptpro.com          [EMAIL PROTECTED]