develooper Front page | perl.perl5.porters | Postings from February 2019

[perl #133827] Bug: An array or hash variable can take an integer asits name.

From:
Tony Cook via RT
Date:
February 11, 2019 04:28
Subject:
[perl #133827] Bug: An array or hash variable can take an integer asits name.
Message ID:
rt-4.0.24-3845-1549859321-801.133827-15-0@perl.org
On Tue, 05 Feb 2019 20:54:35 -0800, demerphq wrote:
> On Wed, 6 Feb 2019, 06:39 Tony Cook via RT <perlbug-followup@perl.org wrote:
> 
> > On Tue, 05 Feb 2019 12:06:23 -0800, twwilliams@k12.wv.us wrote:
> > > On Perl 5.26 on Windows, an array or hash variable can take an integer
> > > as its name.
> > >
> > >     C:> perl -e "@3=(10,20,30); print $3[1]"
> > >     20
> > >     C:>
> > >
> > > Multiple digits work too.
> > >
> > >     C:>perl -e "@217=('aa','bb','cc','dd'); print $217[2]"
> > >     cc
> > >     C:>
> > >
> > > ...and hashes.
> > >
> > >     C:>perl -e "%217=('aa','bb','cc','dd'); print $217{aa}"
> > >     bb
> > >     C:>
> >
> > This isn't a bug.
> >
> > > ...but not scalars.
> > >
> > >     C:>perl -e "$7='seven'; print $7"
> > >     Modification of a read-only value attempted at -e line 1.
> >
> > Neither is this.  Numeric named scalars are reserved for regular
> > expression captures:
> >
> > C:\Users\Tony>perl -le "$_ = 'abc123'; /(\d+)/; print $1"
> > 123
> >
> 
> Note the docs you about below specify *all* vars consisting of pure numbers
> are reserved, it's just that *currently* only the scalars are actually used.

Yeah, they're reserved, we just don't enforce it.

Just like names matching /^_[A-Z]/ in C.

Rejecting this ticket.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=133827



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About