我試圖計算如何將$ opt {p}中的值和直接字符串發送到子例程而不是數組。字符串中的Perl哈希對值
use Getopt::Std;
my $opt_string = 'hdp:j:';
getopts("$opt_string", \%opt) or usage();
usage() if $opt{h};
}
sub usage()
{
print STDERR << "EOF";
This program grabs the problem print request and puts them in folder for investigation.
usage: $0 [-d] [-p printer] [-j job] -h : this (help) message
-p printer: problem printer
-j file : problem print job id
-d : print debugging messages to stderr
example: $0 -p PRINTERQ -j 76063 -d
EOF
exit;
}
sub find_printer
{
my $printer = $_[0] ;
print "Looking for printer $printer .. \n";
}
find_printer($opt{p}) or die "Unable to find printer";
啊好的,謝謝。 – AndyM 2011-05-24 09:35:29