Perl my ($variableName) 和my $variableNamePerl有什么区别?括号怎么办?
mob*_*mob 20
重要的效果是在声明变量的同时初始化变量:
my ($a) = @b; # assigns $a = $b[0]
my $a = @b; # assigns $a = scalar @b (length of @b)
Run Code Online (Sandbox Code Playgroud)
另一个重要的是当你声明多个变量时.
my ($a,$b,$c); # correct, all variables are lexically scoped now
my $a,$b,$c; # $a is now lexically scoped, but $b and $c are not
Run Code Online (Sandbox Code Playgroud)
如果你,最后一句话会给你一个错误use strict.
有关运营商的更多信息,请查看perdoc perlsubmy.这是一个小摘录:
概要:
my $foo; # declare $foo lexically local
my (@wid, %get); # declare list of variables local
my $foo = "flurp"; # declare $foo lexical, and init it
my @oof = @bar; # declare @oof lexical, and init it
my $x : Foo = $y; # similar, with an attribute applied
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4122 次 |
| 最近记录: |