Perl: the Markov chain saw | |
PerlMonks |
Re: Re: Web-Safe Color Chartby trantor (Chaplain) |
on Oct 05, 2001 at 14:19 UTC ( [id://116954]=note: print w/replies, xml ) | Need Help?? |
First of all, glob expands the pattern according to shell
conventions, so glob "foob{a,b,c}r"returns the list ('foobar', 'foobbr', 'foobcr')just like bash would return 'foobar foobbr foobcr' expandig metacharacters The x operator applied to a string repeats the string the specified number of times, so "{a,b,c}" x 3 evaluates as "{a,b,c}{a,b,c}{a,b,c}" When you feed this expression to glob, the result is a list of all the possible combinations of a, b and c in a string of three characters, from 'aaa' to 'ccc'. This could be easily achieved through magical string autoincrement, but the beauty of this method (very nice, I love it!) is that it applies to any set of strings to combine, not just characters. -- TMTOWTDI
In Section
Seekers of Perl Wisdom
|
|