[kw-pm] neat permutations trick..
Daniel R. Allen
da at coder.com
Wed Feb 18 21:18:12 CST 2004
When I tried this in the meeting, I could've sworn I'd tried the same
parameters, but anyway, both of these work; they are un-documented
features of perl's filename expansions, that don't actually require any
files to match, but return a valid array. Courtesy toronto.pm:
bash %> perl -d -e 1
DB<1> @x = glob( "{a,b,c}{1,2,3}" )
DB<2> x @x
0 'a1'
1 'a2'
2 'a3'
3 'b1'
4 'b2'
5 'b3'
6 'c1'
7 'c2'
8 'c3'
DB<3> @x = <{a,b,c}{1,2,3}{doo,dah}>
DB<4> x @x
0 'a1doo'
1 'a1dah'
2 'a2doo'
3 'a2dah'
4 'a3doo'
5 'a3dah'
6 'b1doo'
7 'b1dah'
8 'b2doo'
9 'b2dah'
10 'b3doo'
11 'b3dah'
12 'c1doo'
13 'c1dah'
14 'c2doo'
15 'c2dah'
16 'c3doo'
17 'c3dah'
--
http://coder.com/ - Prescient Code Solutions - (519) 575-3733 da at coder.com
More information about the kw-pm
mailing list