diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-04-11 16:58:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-11 16:58:15 +0100 |
| commit | e4a24c08a3ba2481b7dcb042da385deedb50f1f6 (patch) | |
| tree | 8b19400c8b5124d8180c5e9e398270896062027e /challenge-107 | |
| parent | da4d4619288269591fc42280d940d4b2aa15d6a8 (diff) | |
| parent | 5310eec24b47304ac0460fa67cb5c9ba151e293c (diff) | |
| download | perlweeklychallenge-club-e4a24c08a3ba2481b7dcb042da385deedb50f1f6.tar.gz perlweeklychallenge-club-e4a24c08a3ba2481b7dcb042da385deedb50f1f6.tar.bz2 perlweeklychallenge-club-e4a24c08a3ba2481b7dcb042da385deedb50f1f6.zip | |
Merge pull request #3860 from stuart-little/stuart-little_107_perl
1st commit on 107_perl
Diffstat (limited to 'challenge-107')
| -rwxr-xr-x | challenge-107/stuart-little/perl/ch-1.pl | 16 | ||||
| -rwxr-xr-x | challenge-107/stuart-little/perl/ch-2.pl | 22 |
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-107/stuart-little/perl/ch-1.pl b/challenge-107/stuart-little/perl/ch-1.pl new file mode 100755 index 0000000000..ca5c5e83a1 --- /dev/null +++ b/challenge-107/stuart-little/perl/ch-1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl +use warnings; +use v5.12; + +# run <script> + +my %res = ( + 100 => [4,1210], + 136 => [4,2020], + 1425 => [5,21200], + ); + +for (sort {int $_} keys %res) { + say "Base 10: $_"; + say sprintf("Base %s: %s\n", $res{$_}->[0], $res{$_}->[1]); +} diff --git a/challenge-107/stuart-little/perl/ch-2.pl b/challenge-107/stuart-little/perl/ch-2.pl new file mode 100755 index 0000000000..0e4b6c7406 --- /dev/null +++ b/challenge-107/stuart-little/perl/ch-2.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl +use warnings; +use v5.12; + +# run <script> <path-to-package> +# defaults to warnings.pm + +use File::Basename; +no strict 'refs'; + +my $path = (scalar @ARGV) ? ($ARGV[0]) : ($INC{'warnings.pm'}); +require $path; + +my ($base,$dir,$ext) = fileparse($path,qr/\.[^.]*/); +my @special = qw(BEGIN END INIT CHECK UNITCHECK); + +for my $key (sort keys %{$base . "::"}) { + *glob = ${$base . "::"}{$key}; + if ((defined &glob) || (scalar grep {$_ eq $key} @special)) { + say $key; + } +} |
