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

Re: [perl #132908] String/Number interpretation of a string

Thread Previous | Thread Next
From:
Abigail
Date:
February 26, 2018 11:39
Subject:
Re: [perl #132908] String/Number interpretation of a string
Message ID:
20180226114323.GT24393@almanda.fritz.box
On Sun, Feb 25, 2018 at 02:10:41PM -0800, James E Keenan via RT wrote:
> On Sun, 25 Feb 2018 18:25:19 GMT, perl@ton.iguana.be wrote:
> > 
> > This is a bug report for perl from perl@ton.iguana.be,
> > generated with the help of perlbug 1.40 running under perl 5.20.2.
> > 
> > 
> > -----------------------------------------------------------------
> > [Please describe your issue here]
> > 
> > perl -wlE '$_="-4-5"; say -$_|0'
> > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1.
> > 4
> > 
> > perl -wlE '$_=-4 . -5; say -$_|0'
> > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1.
> > 4
> > 
> > perl -wlE '$_="-4-5"; $_+0; say -$_|0'
> > Useless use of addition (+) in void context at -e line 1.
> > Argument "-4-5" isn't numeric in addition (+) at -e line 1.
> > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1.
> > 4
> > 
> > perl -wlE '$_=-4 . -5; $_+0; say -$_|0'
> > Useless use of addition (+) in void context at -e line 1.
> > Argument "-4-5" isn't numeric in addition (+) at -e line 1.
> > 18446744073709551612
> > 
> > That last one is very unexpected.
> > The same thing happens on perl 5.26.1
> > 
> 
> I do not get the same results as you.


Is that because you're using different code, or because of something else?


> 
> #####
> $ perl -v | head -2 | tail -1
> This is perl 5, version 20, subversion 3 (v5.20.3) built for x86_64-linux
> 
> $ perl -wlE '$_="-4 . -5"; $_+0; say -$_|0'

That's not the same as written in the bug report:

> > perl -wlE '$_=-4 . -5; $_+0; say -$_|0'

Note the absense of quotes around C<< -4 . -5 >> in the report,
while your code puts quotes there.

> Useless use of addition (+) in void context at -e line 1.
> Argument "-4 . -5" isn't numeric in addition (+) at -e line 1.
> Argument "+4 . -5" isn't numeric in bitwise or (|) at -e line 1.
> 4
> 
> $ perl -v | head -2 | tail -1
> This is perl 5, version 26, subversion 0 (v5.26.0) built for x86_64-linux
> 
> $ perl -wlE '$_="-4 . -5"; $_+0; say -$_|0'
> Useless use of addition (+) in void context at -e line 1.
> Argument "-4 . -5" isn't numeric in addition (+) at -e line 1.
> Argument "+4 . -5" isn't numeric in bitwise or (|) at -e line 1.
> 4



Abigail

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