develooper Front page | perl.perl5.porters | Postings from March 2017

Re: [perl #115810] $_[$ref] warnings discrepancy

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
March 21, 2017 12:05
Subject:
Re: [perl #115810] $_[$ref] warnings discrepancy
Message ID:
20170321120504.GA3342@iabyn.com
On Tue, Sep 27, 2016 at 10:04:10AM -0700, Dan Collins via RT wrote:
> On Sun Nov 18 14:38:27 2012, sprout wrote:
> > Pint:perl.git-copy sprout$ ./perl -Ilib -we '() = $_[[]]'
> > Use of reference "ARRAY(0x802a00)" as array index at -e line 1.
> > Pint:perl.git-copy sprout$ ./perl -Ilib -we '() = $_[$/=[]]'
> >  Pint:perl.git-copy sprout$
> > 
> > I would expect the same output from both.

> The latter is now a compile time error, since 5.19.9:
> 
>     Setting $/ to an ARRAY reference is forbidden at -e line 1
> 
> Some special variables still produce no warning or error, including $$,
> so I do not know if this is fixed.

The behaviour is intentional: if the index variable has get or overload
magic, then the warning is skipped, since the 'ref' may return something
other than a large integer when used in numeric context.

Closing.

-- 
This email is confidential, and now that you have read it you are legally
obliged to shoot yourself. Or shoot a lawyer, if you prefer. If you have
received this email in error, place it in its original wrapping and return
for a full refund. By opening this email, you accept that Elvis lives.

Thread Previous | Thread Next


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