如果有人能告诉我如何在此Perl代码中将位置参数更改为命名参数,我将不胜感激。
#!/usr/bin/perl -w
sub diskUsageMon {
my ($hash_ref, $array_ref) = @_;
unless ( open(DF, "df -kh 2>&1 |") ) {
chomp $!;
push $array_ref, "Failed to start command df", "Reason: $!";
return 1;
}; # Unless
while ( <DF> ) {
next if /^Filesystem/;
@df = split;
my ($mount, $use) = @df[5,4];
$hash_ref->{$mount} = $use;
}; # While
close DF;
return 0;
}; # sub
#---------------------------------------------------------#
%hash_ref = ();
@array_ref = ();
if ( &diskUsageMon(\%hash_ref, \@array_ref) ) {
die "Error detected!\n", "Reason: ", join("\n", @array_ref), "\n";
};