首页 > 编程语言 >Perl语言学习

Perl语言学习

时间:2022-08-18 11:26:54浏览次数:61  
标签:right 语言 price perl 学习 文档 100 Perl

  • Here文档
    • #!/bin/perl
      
      $price=100;
      
      # No quotes around terminator EOF are same # as double quotes
      # Variables are expanded
      print <<EOF1;
      The price1 of $price is right.
      EOF1
      print <<"EOF2";
      The price2 of $price is right.
      EOF2
      
      # The variable is not expanded if terminator is enclosed in single quotes
      print <<'FINISH';
      The price of $price is right.
      FINISH
      
      # If terminator is in backquotes, # will execute UNIX commands
      print <<`END`;
      echo hi there
      echo -n "The time is "
      date
      END
      View Code
    • 输出:
      The price1 of 100 is right.
      The price2 of 100 is right.
      The price of $price is right.
      hi there
      The time is Thu 18 Aug 2022 11:12:50 AM CST

      注:Here文档的"<<"右边的标记符用来标记一段文字,可以将遇到下一个相同标记符之前的所有按指定格式存储的内容赋值给"<<"左边的变量,如果左边是print就直接打印右边的内容.例如:
        $a=<< "MARK" #下一行开始,直到遇见"MARK"为止,所有的字符都按照指定的格式存入变量a中.注意perl中定义标量类型(数字,字符串,浮点数)的变量要加$,和shell引用时才加$有区别.

标签:right,语言,price,perl,学习,文档,100,Perl
From: https://www.cnblogs.com/Song-Meow/p/16598033.html

相关文章