aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2019-10-12 19:47:19 +0200
committerLubos Kolouch <lubos@kolouch.net>2019-10-12 19:47:19 +0200
commit544ef7c7d230ad9bb600f503bfdf62f305523353 (patch)
tree84ae519e9c7338713c5e7160eb94ca9c5a25a5f3
parent9abb23c578cb523a2afddacd2ac03b4a72b9f52e (diff)
downloadperlweeklychallenge-club-544ef7c7d230ad9bb600f503bfdf62f305523353.tar.gz
perlweeklychallenge-club-544ef7c7d230ad9bb600f503bfdf62f305523353.tar.bz2
perlweeklychallenge-club-544ef7c7d230ad9bb600f503bfdf62f305523353.zip
Challenge 029 - 1 LK
-rw-r--r--challenge-029/lubos-kolouch/perl5/ch-1.pl52
1 files changed, 52 insertions, 0 deletions
diff --git a/challenge-029/lubos-kolouch/perl5/ch-1.pl b/challenge-029/lubos-kolouch/perl5/ch-1.pl
new file mode 100644
index 0000000000..d861407d50
--- /dev/null
+++ b/challenge-029/lubos-kolouch/perl5/ch-1.pl
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+#===============================================================================
+#
+# FILE: ch-1.pl
+#
+# USAGE: ./ch-1.pl
+#
+# DESCRIPTION: https://perlweeklychallenge.org/blog/perl-weekly-challenge-029/
+#
+# Write a script to demonstrate brace expansion. For example, script would
+# take command line argument Perl {Daily,Weekly,Monthly,Yearly} Challenge and
+# should expand it and print like below:
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: YOUR NAME (),
+# ORGANIZATION:
+# VERSION: 1.0
+# CREATED: 10/11/2019 03:56:17 PM
+# REVISION: ---
+#===============================================================================
+
+use strict;
+use warnings;
+use feature qw/say/;
+use Data::Dumper;
+use Text::Glob::Expand;
+
+sub expand_brace {
+ my $words = shift;
+
+ my $glob = Text::Glob::Expand->parse($words);
+ my $permutations = $glob->explode_format("");
+
+ return $permutations;
+
+}
+my ($words) = @ARGV;
+
+my $permutations = &expand_brace($words);
+
+say for keys %$permutations;
+
+#-------- TEST ---------
+use Test::More;
+
+$permutations = &expand_brace('Perl {Daily,Weekly,Monthly,Yearly} Challenge');
+is(keys %$permutations,4);
+
+