Perl常用文法記録
998 ワード
Perl常用文法記録
##
#package A;
#my $a=10;
#package B;
#print $A::a;
#print $a;
##local
#$aa=20;
#{
# local $aa;
# $aa=10;
# print "$aa
";
#
#}
#print $aa;
##
=comment
$b=10;
$a=1;
$c=200;
{
local *b;
*b=*a;
$b=20;
print "$a
";
}
*d=*c;
$d=100;
print "$a
";
print "$b
";
print "$c
";
print "$d
";
=cut
## , ,
my @array=(10,20);
xxxx(\@array);
print "@array
";
sub xxxx{
my $copy=shift;
foreach $item (@$copy){
$item=$item*2;
}
for $row ($copy) {
print "@$row
";
}
print "@$copy
";
}
##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};
}