my %myHash = ("age"=>"25","name"=>"jayden");
my $val1 = \%myHash;
print ${$val1}{"age"};
if(`echo \$PWA` =~ /.*\/default$/){
print <<END;
*********************************************************
[ERROR]
*********************************************************
END
exit(0);
}
<<END表示可以打印到END為止。
my $tl_path = "$p4client_root/dig/verif/$tl";
unless (-f $tl_path) {die "$tl_path is not found\n";}
my %hash;
my @uniq_name = grep{++$hash{$_}==1} @name;
`p4 client -o > client_info.txt`;
system qq(echo " //ZZ/$proj_name/dig/COMMON/verif/testlists/$testlist //$p4client_name/dig/COMMON/verif/testlists/$testlist" >> client_info.txt);
`p4 client -i < client_info.txt`
system qq(p4 sync $p4client_root/...#head 2>&1 | grep -v 'up-to-date');
利用p4 client可以設定depot 和 local mapping 關係。
qq ( string ) function returns a double-quoted string
grep
function is used to filter lists. The basic syntax is
@out = grep { CODE } @in;
where CODE
is some Perl code. For each element of @in
, CODE
is executed with $_
set to the element.
If the code returns a true value, the element is placed in the output list; otherwise it is discarded.
my %hash;
my @uniq_name = grep{++$hash{$_}==1} @name;
上述代碼可實現去除數組中重複的元素。
2>&1:(combine stderr
and stdout
into the stdout
stream)
File descriptor 1 is the standard output (stdout
).
File descriptor 2 is the standard error (stderr
)