YUANya

导航

 

数字与字符串

#!/usr/bin/envperl

use strict;
use warnings;


##加斜表示同一个数字

my $number = 124567890;

my $new_number = 1_2_3456_7890;

print "$number = $new_number\n";


##不同进制的数字

my $octal_number = 0017;

my $hexadecimal_number = 0x0f;

my $binary_number = 0b0000_1111;

my $decimal_number = 15;

print"$octal_number=$hexadecimal_number=$binary_number=$decimal_number\n";


##加入除ASCII以外字符时使用Unicode编码

use utf8

print "\x{2668}\n";


##关于大小括号显示空白,相同效果

print "a b c\n";

print 'a b c'."\n";


##little x

print 5 x 4;

print "\n";

print 5 x 4.8;

print "\n";


##multiplication

print "12"*"3"."\n";

print "12apple34" * "3"."\n";


##warning details

use diagnostics


##

result
Wide character in print at test.pl line 33.

124567890 = 1234567890
15=15=15=15
a b c
a b c
5555
5555
36
Argument “12apple34” isn’t numeric in multiplication (*) at test.pl line 58 (#1)
(W numeric) The indicated string was fed as an argument to an operator
that expected a numeric value instead. If you’re fortunate the message
will identify which operator was so unfortunate.

Note that for the Inf and NaN (infinity and not-a-number) the
definition of "numeric" is somewhat unusual: the strings themselves
(like "Inf") are considered numeric, and anything following them is
considered non-numeric.

36

posted on 2019-06-07 23:54  YUANya  阅读(162)  评论(0编辑  收藏  举报