拜托,任何人都可以帮助我:
perl -e 'print for <{a,b,c}{1,2,3}>'
我只是不明白它是如何工作的.它的工作原理!生产
a1a2a3b1b2b3c1c2c3
在输出上.
有谁知道钻石操作符内部发生了什么?
解决方法
这是代表
glob
bing的另一种方式.基本上,curlies告诉glob操作符将每个逗号分隔的元素放在内部并结合所有可能性.
$perl -e 'print join ",",<{a,3}>;' a1,a2,a3,b1,b2,b3,c1,c2,c3
从perldoc -f glob
开始:
If non-empty braces are the only wildcard characters used in the glob,
no filenames are matched,but potentially many strings are returned.
For example,this produces nine strings,one for each pairing of
fruits and colors:06001