Please, can anyone help me with this:
perl -e 'print for <{a,b,c}{1,2,3}>'
I just don't understand how it works. And it works! Producing
a1a2a3b1b2b3c1c2c3
on output.
Does anyone know what is happening inside diamond operator?
Please, can anyone help me with this:
perl -e 'print for <{a,b,c}{1,2,3}>'
I just don't understand how it works. And it works! Producing
a1a2a3b1b2b3c1c2c3
on output.
Does anyone know what is happening inside diamond operator?
It's another way to represent
glob
bing. Basically the curlies tell theglob
operator to take each comma-separated element inside and combine across all possibilities.A clearer way to see this is to comma-separate the individual outputs:
From
perldoc -f glob
: