
Deconstructed
If you understand what this does:
echo {A,B}{A,B,C}{A,B}
then you shouldn't be surprised at
perl -e'print"$_\\n"for glob"{A,B}{A,B,C}{A,B}"'
The key is therefore how to produce that string. Well we do it as:
perl -e'print"$_\\n"for glob join"","{A,B}","{A,B,C}","{A,B}"'
Now we just need to produce those. Well our first trick is $" and array interpolation. If you set $" to ",", then a list interpolates into a string with comma separators. So with that global set, "@{[A..C]}"
is "A,B,C"
. Slap braces around that, and you see what "{@{[A..$_]}}"
does.
Now we just need to get the right list of characters. BCB=~/./g
does that in list context, which we are in. (I didn't think of that trick at first. My initial versions in the revision history used split.)
And that's it.
Cheers,
Ben
PS You will note that I am making liberal use of unquoted barewords as strings. This wouldn't exactly pass strict, but I don't have that on so I don't care.
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]