Skip to content

[doc] perlnumber: Negative octal number as a string evaluates to decimal number in numeric operations #18583

@rsFalse

Description

@rsFalse

Where

https://perldoc.perl.org/perlnumber#SYNOPSIS

Description

Seems undocumented behavior. Quoted negative octal number evaluates to decimal:

(perl v5.32.0)

#!/usr/bin/perl

use warnings;
use strict;

$\ = $/;

my $A = -010;
my $B = "-010";
my $C = "- 010";

print map "[$_]", 
	$A, $B, $C,
	;

print map "[$_]", map $_ + 1,
	$A, $B, $C,
	;

print map "[$_]", map ++ $_,
	$A, $B, $C,
	;

OUTPUT:

[-8][-010][- 010]
Argument "- 010" isn't numeric in addition (+) at negative_octal_1.pl line 16.
[-7][-9][-9]
[-7][-9][-9]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions