Skip to main content


$ perl -E 'say "positive" if(shift() + 0 > 0)' "information"
positive
$ perl -E 'say "positive" if(shift() + 0 > 0)' "in formation"
$

LOL #perl

#perl
in reply to Paul Evans

@leonerd I assume that the culprit is strtosomething and that this ridiculous behaviour is required by #POSIX. We should fix that in #POSEVEN.
in reply to David Cantrell 🏏

@leonerd No, it's just Perl's usual "parse as much numeric stuff at the start of the string as possible, then warn if there's crud after it":
$ perl -wE 'say "42wibble" + 0'<br>Argument "42wibble" isn't numeric in addition (+) at -e line 1.<br>42<br>$ perl -wE 'say "informal" + 0'<br>Argument "informal" isn't numeric in addition (+) at -e line 1.<br>Inf<br>
in reply to ilmari

@ilmari @leonerd right, but what is Perl using to parse the string? I could RTFsource and find out, but that would mean getting out of bed πŸ˜€
in reply to David Cantrell 🏏

@leonerd it has its own grok_number function.
⇧