perlquestion
vrk
<p>
Dear monks,
</p>
<p>
I was reading the manual entry for [doc://glob] the other day, and discovered a feature I hadn't used before: brace-only "wildcard" expressions can be used to generate strings with no globbing behaviour (that is, no matching against filenames in the current directory). The manual gives one example:
</p>
<code>
@many = glob "{apple,tomato,cherry}={green,yellow,red}";
</code>
<p>
It's closely related to the Perl 6 "X" operator, but limited to string elements only.
</p>
<p>
It's fun to try different ways to generate all pairs, triples or tuples of some length. For example, the following prints the coordinates of the standard chessboard:
</p>
<code>
perl -E '$" = ","; my @pos = 'a'..'h'; say for <{@pos}{@{[ 1..@pos ]}}>'
</code>
<p>
Other than toy examples, have you used this kind of a glob in production code? What kind of non-trivial use cases can you suggest?
</p>