# 선언 부분
my %_list = (
'key1' => 0, # 대한통운
'key2' => 0, # 한진택배
);
printf "작업 시작\n";
# 작업 부분
while ( my ($key, $value) = each( %_list ) ) {
print "$key => $value\n";
}
# 소멸
delete $hash{$key};
# 사이즈
print "size of hash: " . keys( %hash ) . ".\n";
# function ref return
sub foo
{
my ( $login, $p, $uid, $gid, $gecos, $dir, $s );
my %HoH = ();
my $file = '/etc/passwd';
open( PASSWD, "< $file" ) or die "Can't open $file : $!";
while( <PASSWD> ) {
( $login, $p, $uid, $gid, $gecos, $dir, $s ) = split( ':' );
$HoH{ $login }{ 'uid' } = $uid;
$HoH{ $login }{ 'gid' } = $gid;
$HoH{ $login }{ 'dir' } = $dir;
}
close PASSWD;
return \%HoH;
}
댓글 없음:
댓글 쓰기