Chinaunix首页 | 论坛 | 博客
  • 博客访问: 360896
  • 博文数量: 79
  • 博客积分: 1270
  • 博客等级: 中尉
  • 技术积分: 1370
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-12 08:48
个人简介

freedom~~~~~~~~~~

文章分类

全部博文(79)

文章存档

2014年(10)

2013年(2)

2012年(13)

2011年(54)

分类: Python/Ruby

2012-12-29 14:29:57


点击(此处)折叠或打开

  1. #!/usr/bin/perl
  2. $tmp1 = 1;
  3. $tmp2 = $tmp1 + 1;
  4. $tmp3 = $tmp2 * 2;
  5. print "$tmp3 \n";
  6. $tmp4 = "this";
  7. $tmp5 = $tmp4 . $tmp3;
  8. print "tmp5 is $tmp5\n";

  9. print "hello world\n";
  10. print "---- $tmp5 \n";
  11. print $tmp5."\n";

  12. while($tmp3 < 10)
  13. {
  14.        print "Current tmp3 is $tmp3\n";
  15.        $tmp3 ++;
  16. }

  17. #chomp 读入去掉空格

  18. $text1 = "this is input \n";
  19. chomp($text1);
  20. print $text1."\n";


  21. $text2 = <STDIN>;
  22. #含有换行
  23. print "the use typed ---- $text2 \n";
  24. chomp($text2);
  25. print "the use typed ---- $text2 \n";

  26. # $ARGV[0,1,2,3]获取命令行参数内容
  27. # $#ARGV获取最后一个元素索引

  28. if( $#ARGV != -1)
  29. {
  30.         print "has $#ARGV \n";
  31.         for($i = 0;$i <= $#ARGV; $i ++)
  32.         {
  33.                 $tmp = $i + 1;
  34.                 print "the $tmp is $ARGV[$i] \n";
  35.         }
  36. }

  37. system("echo helloworld");

  38. sub function
  39. {
  40.         $pm_n = $#_ + 1;
  41.         if($pm_n == 1)
  42.         {
  43.                 printf("return error\n");
  44.                 return "error";
  45.         }
  46.         print "the perameter num is $pm_n\n";
  47.         print "the perameter is @_ \n"; #参数在一起
  48.         print "the first perameter is @_[0] \n"; #参数1
  49.         print "the second perameter is @_[1] \n"; #参数2
  50.         return 0;
  51. }

  52. $result = function(1);
  53. print "---the first call of function is $result \n";
  54. $result = function(2,3);
  55. print "---the second call of function is $result \n";
  56. $pa = "hello";
  57. $pb = "world";
  58. $result = function($pa,$pb);
  59. print "+++the third call of function is $result \n";

阅读(1409) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~