zoukankan      html  css  js  c++  java
  • 小骆驼 第二章 标量数据

    数字与字符串

    #!/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

  • 相关阅读:
    2017ecjtu-summer training # 9 HDU 4544
    2017ecjtu-summer training #6 Gym 100952D
    HDU 1241 DFS
    集训队选拔赛 day4
    Educational Codeforces Round 67 (Rated for Div. 2)
    Codeforces Round #566 (Div. 2)
    Codeforces Round #567 (Div. 2)
    Codeforces Round #568 (Div. 2)
    Codeforces Round #569 (Div. 2)
    牛客练习赛48
  • 原文地址:https://www.cnblogs.com/yuanjingnan/p/11061489.html
Copyright © 2011-2022 走看看