aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-10-27 10:29:27 +0000
committerGitHub <noreply@github.com>2019-10-27 10:29:27 +0000
commit20e4afaca02dbedd396b7e1f76aa63c09c347d57 (patch)
treeb4ddfa05193a6193e2f84c1e09150d3320b20c49
parente640239889e5b705bc6b153ee78954cf0443087b (diff)
parentb943d00179cece6a1b38b501c442906971f5ec0b (diff)
downloadperlweeklychallenge-club-20e4afaca02dbedd396b7e1f76aa63c09c347d57.tar.gz
perlweeklychallenge-club-20e4afaca02dbedd396b7e1f76aa63c09c347d57.tar.bz2
perlweeklychallenge-club-20e4afaca02dbedd396b7e1f76aa63c09c347d57.zip
Merge pull request #845 from kolcon/master
Ch2 LK Python
-rw-r--r--challenge-031/lubos-kolouch/perl5/ch-2.pl49
1 files changed, 49 insertions, 0 deletions
diff --git a/challenge-031/lubos-kolouch/perl5/ch-2.pl b/challenge-031/lubos-kolouch/perl5/ch-2.pl
new file mode 100644
index 0000000000..67c505e3f5
--- /dev/null
+++ b/challenge-031/lubos-kolouch/perl5/ch-2.pl
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+#===============================================================================
+#
+# FILE: ch-2.pl
+#
+# USAGE: ./ch-2.pl
+#
+# DESCRIPTION: https://perlweeklychallenge.org/blog/perl-weekly-challenge-031/
+#
+# Create a script to demonstrate creating dynamic variable name, assign a value to the variable and finally print the variable. The variable name would be passed as command line argument.
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: Lubos Kolouch
+# ORGANIZATION:
+# VERSION: 1.0
+# CREATED: 10/27/2019 10:03:56 AM
+# REVISION: ---
+#===============================================================================
+
+use strict;
+use warnings;
+use feature qw/say/;
+use Test::More;
+
+sub assing_variable {
+ my $var_name = shift;
+ no strict 'refs';
+
+ # it works, but I would not like to debug it...
+ ${$var_name} = "test";
+ return 1;
+}
+
+my $name = $ARGV[0] or die 'Usage: ch-2.pl name';
+assing_variable($name);
+
+# TESTS
+
+$name='bla';
+assing_variable($name);
+
+no strict 'refs';
+is($$name,'test');
+
+done_testing();
+