diff options
| -rwxr-xr-x | challenge-029/duane-powell/perl5/ch-1.pl | 47 | ||||
| -rwxr-xr-x | challenge-029/duane-powell/perl5/ch-2.pl | 16 |
2 files changed, 63 insertions, 0 deletions
diff --git a/challenge-029/duane-powell/perl5/ch-1.pl b/challenge-029/duane-powell/perl5/ch-1.pl new file mode 100755 index 0000000000..2b963f3e41 --- /dev/null +++ b/challenge-029/duane-powell/perl5/ch-1.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl +use Modern::Perl; +use Text::Glob::Expand; + +usage() unless @ARGV==1; + +my $glob = Text::Glob::Expand->parse($ARGV[0]); +my $permutations = $glob->explode_format(""); +say foreach (keys %{$permutations} ); + +sub usage { + print <<EOU; +Usage: $0 'brace-expansion' + +Note: 'brace-expansion' must be quoted to surpress bash brace expansion, ironic. +Examples: + $0 'Perl {Daily,Weekly,Monthly,Yearly} Challenge' # PWC 29 + $0 'It{{em,alic}iz,erat}e{d,}' # test from RosettaCode + $0 '{,{,gotta have{ ,\, again\, }}more }cowbell!' # '' + $0 'mkdir -p ~/project/{src,docs,test,foo}' # practical usage + $0 'apt-get install lib{file-find-rule,test-more}-perl' # '' +EOU + exit; +} + + +__END__ + +./ch-1.pl 'Perl {Daily,Weekly,Monthly,Yearly} Challenge' +Perl Daily Challenge +Perl Weekly Challenge +Perl Monthly Challenge +Perl Yearly Challenge + +./ch-1.pl 'It{{em,alic}iz,erat}e{d,}' +Italicize +Iterate +Itemized +Italicized +Iterated +Itemize + +./ch-1.pl '{,{,gotta have{ ,\, again\, }}more }cowbell!' +gotta have more cowbell! +more cowbell! +gotta have, again, more cowbell! +cowbell! diff --git a/challenge-029/duane-powell/perl5/ch-2.pl b/challenge-029/duane-powell/perl5/ch-2.pl new file mode 100755 index 0000000000..def5624c4b --- /dev/null +++ b/challenge-029/duane-powell/perl5/ch-2.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl +use strict; +use Inline C => <<'EOC'; + +void pwc() { + printf("Perl Weekly Challenge 029 Inline-C example!\n"); +} +EOC + +pwc(); + +__END__ + +./ch-2.pl +Perl Weekly Challenge 029 Inline-C example! + |
