diff options
| -rw-r--r-- | challenge-021/dave-cross/perl5/ch-1.pl | 27 | ||||
| -rw-r--r-- | challenge-021/dave-cross/perl5/ch-2.pl | 22 |
2 files changed, 49 insertions, 0 deletions
diff --git a/challenge-021/dave-cross/perl5/ch-1.pl b/challenge-021/dave-cross/perl5/ch-1.pl new file mode 100644 index 0000000000..ff73950dc2 --- /dev/null +++ b/challenge-021/dave-cross/perl5/ch-1.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use feature 'say'; + +my ($curr, $last) = (1, 0); +my $iter = 1; + +do { + # say $iter; + $last = $curr; + $curr += (1 / ( fact($iter++))); +} until ($last == $curr); + +say $curr; + +sub fact { + my ($x) = @_; + + my $fact = 1; + while ($x) { + $fact *= $x--; + } + + return $fact; +} diff --git a/challenge-021/dave-cross/perl5/ch-2.pl b/challenge-021/dave-cross/perl5/ch-2.pl new file mode 100644 index 0000000000..e0bd00d094 --- /dev/null +++ b/challenge-021/dave-cross/perl5/ch-2.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use feature 'say'; + +use URI; + +if (!@ARGV) { + @ARGV = <DATA>; + chomp(@ARGV); +} + +for (@ARGV) { + say URI->new($_)->canonical; +} + +__DATA__ +HTTP://www.Example.com/ +http://www.example.com/a%c2%b1b +http://www.example.com/%7Eusername/ +http://www.example.com:80/bar.html |
