我想寻求帮助来创建一个 Perl 代码,我可以在其中创建字母数字顺序变量(可以用作数组、散列或任何其他类型的变量)。
for ( my $x = 1; $x <= 10; $x++ ){
my $var$x = "" *# to create empty variable with the word 'var' + the integer from x (var1, var2, var3, ...)*
for ( my $y = 1; $y < 10; $y++){
my $var$x = $var$x.''.$x.''.$y *# to store/concatenate the values from $x+$y into var$x*
}
print "$var$x"
}
Run Code Online (Sandbox Code Playgroud)
应该打印什么:
var1 = 11, 12, 13, 14, 15, 16, 17, 18, 19
var2 = 21, 22, 23, …Run Code Online (Sandbox Code Playgroud)