• 小骆驼 第三章 列表与数组


    列表

    #!/usr/bin/envperl
    
    use strict;
    use warnings;
    
    
    if( ( 1 , 2 , 3 ) eq ( 1 , 2 , 3 , ) ) 
    {
    print "right\n";
    }
    else
    {
    print "wrong\n";
    }
    
    ##right
    
    if( ( 1..3 ) eq ( 1 , 2 , 3 ) )
    {
    print "right\n";
    }
    else
    {
    print "wrong\n";
    }
    
    ##wrong
    
    if( ( 1.1 , 2.2 , 3.3 ) == ( 1 , 2 , 3 ) )
    {
    print "right\n";
    }
    else
    {
    print "wrong\n";
    }
    
    ##wrong
    
    my $three =3;if( ( 1 , 2 , $three ) eq ( 1 , 2 , 3 ) )
    {
    print "right";
    }
    else
    {
    print "wrong";
    }
    
    ##right
    

    问题一:如何比较两个数组?
    问题二:为什么会在比较时,出现实数值为空的现象?

    Useless use of a constant (2) in void context at test.pl line 8.
    Useless use of a constant (2) in void context at test.pl line 8.
    Useless use of a constant (2) in void context at test.pl line 19.
    Useless use of a constant (2) in void context at test.pl line 30.
    Useless use of a constant (1.1) in void context at test.pl line 30.
    Useless use of a constant (2.2) in void context at test.pl line 30.
    Useless use of a constant (2) in void context at test.pl line 41.
    Useless use of a constant (2) in void context at test.pl line 41.
    right
    Use of uninitialized value $. in range (or flip) at test.pl line 18.
    wrong
    wrong
    right
    

    感恩:今天被大佬教育了!
    list应该遍历后再比较!

    #!/usr/bin/envperl
    
    use trict;
    use warnings;
    
    
    foreach ( 1 , 2 , 3 ) 
    {
      print "$_";
    }
      print "\n"; 
    
    ##123
    
    foreach ( 1..3 ) 
    {
      print "$_";
    }
      print "\n"; 
    
    ##123
    
    foreach ( 1 , 2 , 3, ) 
    {
      print "$_";
    }
      print "\n"; 
    
    ##123
    
    my $three = 3;
    foreach ( 1 , 2 , $three ) 
    {
      print "$_";
    }
      print "\n"; 
    
    ##123
    
  • 相关阅读:
    flash模拟EEROM
    FATFS_SD卡
    AFIO
    ADC1多通道_DMA_内部温度传感器+内部VREFINT
    QmlBook--Meet Qt 5
    NRF24L01
    MWC飞控V2.3串口通信协议——new Multiwii Serial Protocol
    thread相关http://blog.csdn.net/forwayfarer/article/details/3455130
    comparable与comparator的区别http://blog.csdn.net/mageshuai/article/details/3849143
    ArrayList和LinkedList的区别http://pengcqu.iteye.com/blog/502676
  • 原文地址:https://www.cnblogs.com/yuanjingnan/p/11061485.html
Copyright © 2020-2023  润新知