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

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

Thread Previous | Thread Next
Dave Mitchell
March 21, 2017 12:05
Re: [perl #115810] $_[$ref] warnings discrepancy
Message ID:
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.


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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About