で定義されていない限り、コードを持ってみましょう:割り当て値perlの
use 5.014;
use warnings;
my $def = 'default_value';
# this works,.
# e.g. unless here are some arguments
# assigns to element0 the value $def
my(@arr) = (@ARGV);
push @arr, $def unless @arr;
say "args: @arr";
# this also works
# same for scalar - ARGV[0]
my $a1 = $ARGV[0] // $def;
say "arg1: $a1";
は、アレイにデフォルト値を割り当てるためにいくつかの短縮方法は存在しない場合はここには@ARGV
?
#this not works
#my(@arr) = (@ARGV) // ('def');
@ikegamiああ、ありがとう。ちょうどそれを修正しようと編集していた - これは良いです – zdim
ああ...ありがとう。 :) – kobame