diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-10-11 15:27:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-11 15:27:31 +0100 |
| commit | 76ba331a426a651b8cae098b8374eba0d04389c6 (patch) | |
| tree | 20c51cef56c2975c8d40fa71c13c854413ee37bc | |
| parent | d4b4b2ae061213762aaf383cb4952c33b5dc2a38 (diff) | |
| parent | 0e0ff31678b4012df0952ee5b55c96166927f937 (diff) | |
| download | perlweeklychallenge-club-76ba331a426a651b8cae098b8374eba0d04389c6.tar.gz perlweeklychallenge-club-76ba331a426a651b8cae098b8374eba0d04389c6.tar.bz2 perlweeklychallenge-club-76ba331a426a651b8cae098b8374eba0d04389c6.zip | |
Merge pull request #742 from oWnOIzRi/week029
add week 29 task 1 solution
| -rw-r--r-- | challenge-029/steven-wilson/perl5/ch-1.pl | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-029/steven-wilson/perl5/ch-1.pl b/challenge-029/steven-wilson/perl5/ch-1.pl new file mode 100644 index 0000000000..4a122f9dbe --- /dev/null +++ b/challenge-029/steven-wilson/perl5/ch-1.pl @@ -0,0 +1,31 @@ +#!/usr/bin/env perl +# Author: Steven Wilson +# Date: 2019-10-09 +# Week: 029 + +# Task #1 +# 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: +# +# Perl Daily Challenge +# Perl Weekly Challenge +# Perl Monthly Challenge +# Perl Yearly Challenge + +use strict; +use warnings; +use feature qw/ say /; + +my $cmd_line_arg = "Perl {Daily,Weekly,Monthly,Yearly} Challenge"; +say "The command line argument \"$cmd_line_arg\" should expand to:"; + +if ( $cmd_line_arg =~ m/\{([\w\,]*)\}/ ) { + my @items = split /,/, $1; + for my $item (@items) { + my $string = $cmd_line_arg; + $string =~ s/\{[\w\,]*\}/$item/; + say $string; + } +} + |
