Re: 執行檔的參數處理
我自問自答一下
剛試了一下Std和Long的差別
Std: getopts("abc", \%opts) 他會依順序parse @ARGV直到第一個不符合"abc"
如果參數是這樣 -a -b somefile -c
%opts : {'a' => 1, 'b' => 1}
那最後@ARGV裡會剩('somefile', '-c')
Long: GetOptions(
"a" => \$a,
"b" => \$b,
"c" => \$c
)
在 -a -b somefile -c後
$a = 1, $b = 1, $c = 1
而@ARGV = ('somefile');
--
Perl真是好物..
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.143.215.28
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):