2012年9月10日
摘要: index rindex substr:my $part = substr($string, $initial_position, $length); //可为负数,最后-1。-2 -3... my $string = "Hello, world!"; substr($string, 0... 阅读全文
posted @ 2012-09-10 20:55 飞翔@骑士 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 循环的默认控制变量为$_ 参数数组@_ sub max { $max = shift @_; foreach(@_) { if ($_ > $max) { $max = $_; } } $max; } $maxNum = &max (1, 5, 3, 2); //列表可能为空, 调用者得注意返回值可能为undef my($num) = @_; #list context, same with ($num) = @_; return the first one of parameters. my $num ... 阅读全文
posted @ 2012-09-10 16:25 飞翔@骑士 阅读(131) 评论(0) 推荐(0) 编辑