aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-029/dave-cross/perl5/ch-1.pl22
-rw-r--r--challenge-029/dave-cross/perl5/ch-2.pl16
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-029/dave-cross/perl5/ch-1.pl b/challenge-029/dave-cross/perl5/ch-1.pl
new file mode 100644
index 0000000000..f7b741e1db
--- /dev/null
+++ b/challenge-029/dave-cross/perl5/ch-1.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature 'say';
+
+@ARGV or die "Please give me at least one string.\n";
+
+for (@ARGV) {
+ say for brace_expand($_);
+}
+
+sub brace_expand {
+ my ($string) = @_;
+
+ my $braced;
+ unless (($braced) = $string =~ /\{(.+?)}/) {
+ return $string;
+ }
+
+ return map { $string =~ s/\{.+?}/$_/r; } split /,/, $braced;
+}
diff --git a/challenge-029/dave-cross/perl5/ch-2.pl b/challenge-029/dave-cross/perl5/ch-2.pl
new file mode 100644
index 0000000000..3b69712105
--- /dev/null
+++ b/challenge-029/dave-cross/perl5/ch-2.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Inline C => <<'END_OF_C';
+
+void hello(char* name) {
+ printf("Hello, %s\n", name);
+}
+
+END_OF_C
+
+my $name = shift || 'Perl';
+
+hello($name);