具有重复子串的Perl重复串
我正在尝试fbeq00000000000000000000在终端中使用 perl打印一个字符串。
为了避免输入太多我正在使用的零
perl -e 'print "fbeq" . "0" x 20'
现在,我想打印fbeq0000000000000000000020 次,我想用它来实现
perl -e 'print "fbeq" . "0" x 20 x 20'
这给了我不正确的输出: fbeq0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
我想要的是
fbeq00000000000000000000fbeq00000000000000000000fbeq00000000000000000000fbeq00000000000000000000fbeq00000000000000000000 ....
我如何做到这一点?
编辑:我试过:
perl -e 'print ("fbeq" . "0" x 20) x 20'结果不正确。
回答
您可以使用括号:
perl -e 'print(("fbeq" . "0" x 20) x 20)'
- @skrrrt The issue with that other attempt is explained in [operators - Why is 'print (52-80)*42' different than 'print 42*(52-80)' in Perl? - Stack Overflow](https://stackoverflow.com/questions/3806368/why-is-print-52-8042-different-than-print-4252-80-in-perl)