Common Perl syntax records
##包的切换和调用其它包的方式#package A;#my $a=10;#package B;#print $A::a;#print $a; ##local局部标识符的使用#$aa=20;#{#local $aa;#$aa=10;#print "$aa \n";##}#print $aa;##别名的使用=comment$b=10;$a=1;$c=200;{local *b;*b=*a;$b=20;print "$a \n";}*d=*c;$d=100;print "$a \n";print "$b \n";print "$c \n";print "$d \n";=cut##函数传递数组参数,改变数组的内容,打印数组内容my @array=(10,20);xxxx(\@array);print "@array \n";sub xxxx{my $copy=shift; foreach $item (@$copy){$item=$item*2;} for $row ($copy) {print "@$row\n";}print "@$copy \n";}##hash变量声明,赋值,循环输出my %hHashinfo=(‘a‘=>,‘b‘=>2);my %hTableinfo=();### 读取记录数据while ( my @recs = $sth->fetchrow_array ) {$hTableinfo{ $recs[0] } = ( $recs[6] - $recs[3] ) / $recs[6];}foreach my $key ( keys %hTableinfo ) {my $value = $hTableinfo{$key}; }
This article is from the "day with it" blog, please be sure to keep this source http://raugher.blog.51cto.com/3472678/1561839
Common Perl syntax records