zoukankan      html  css  js  c++  java
  • Perl中的小知识点

    1. uc()和lc()函数:

    1 $side = uc($attrs[0]);  #把attrs[0]转换成大写,然后给side变量赋值
    2 $side = lc($attrs[1]);  #把attrs[1]转换成小写,然后给side变量赋值

     2.perl中的内置变量

    字母 符号 释义
    eq  == equal(等于)
    ne != not equal(不等于)
    cmp  <=> 比较
    qq  “” 双引号
    q ‘’ 单引号
    qw    (“”,“”) 等价于带双引号和括号逗号的列表
    $&   正则表达式中匹配字符存放处
    $!   系统产生的信息
    @ARGV   包含从命令行得到的所有参数
    $|   =1表示清除缓存,表示程序无需进入缓存区,直接print
    $* 命令行参数:1 2 3  “1 2 3”
    $@   "1", "2", "3"
    $#   3(3个参数)

     

     

     

     

     

     

     

     

     

     

     

     

     

    3.范围操作符 .. (两个英文点)  该操作符将从左边的数字计数到右边,每次加1以此产生一连串数字

    1 @tmp = (1..5); # 等价于 (1, 2, 3, 4, 5)

     4.乘幂运算符 **

    1 my $a = 2;
    2 my $b = 4;
    3 my $c = $a ** $b;
    4 print '$a ** $b = ' . $c . "
    ";
      输出 $a ** $b = 16

     5.内置常量$&、$`、$' 的用法

    引自:https://blog.csdn.net/numen610/article/details/52619384

    1 $&    是匹配到的字符串
    2 $`    是匹配到字符串其余左边的内容
    3 $'    是匹配到字符串其余右边的内容

     6.heredoc 用法 :$a =<< EOF

    1 $a=<< “EOF”;
    2 this is line 1
    3 this is line 2
    4 EOF
    5 那么变量a中的值就为 this is line 1
    this is line 2
    6 而EOF外的引号,表示在heredoc中的变量会被实际值替代。

    7.heredoc 用法 :print 命令句柄<< "EOF"

    1 print FASTLOAD << “EOF”;
    2 this is line 1
    3 this is line 2
    4 EOF
    5 FASTLOAD 是命令句柄;
    6 那么命令后接的描述语句就为 this is line 1
    this is line 2
    7 EOF为结束标志
    8 而EOF外的引号,表示在heredoc中的变量会被实际值替代。
  • 相关阅读:
    【转】 java中Class对象详解和类名.class, class.forName(), getClass()区别
    106. Construct Binary Tree from Inorder and Postorder Traversal
    105. Construct Binary Tree from Preorder and Inorder Traversal
    107. Binary Tree Level Order Traversal II
    109. Convert Sorted List to Binary Search Tree
    108. Convert Sorted Array to Binary Search Tree
    110. Balanced Binary Tree
    STL容器迭代器失效问题讨论
    113. Path Sum II
    112. Path Sum
  • 原文地址:https://www.cnblogs.com/xuhaojun/p/9414722.html
Copyright © 2011-2022 走看看