aboutsummaryrefslogtreecommitdiff
path: root/challenge-019
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-08-02 12:08:29 +0100
committerGitHub <noreply@github.com>2019-08-02 12:08:29 +0100
commit874f4e5d4d63511f4c318fd39c36fab83322efbc (patch)
tree559f63602b5a39188bb415b1de3bfbd52d6eb027 /challenge-019
parent631c2ce30e029b24c1e41bd16276dbc663024403 (diff)
parent688a12608e5a10e6a2577498eb286bf0b6b2988b (diff)
downloadperlweeklychallenge-club-874f4e5d4d63511f4c318fd39c36fab83322efbc.tar.gz
perlweeklychallenge-club-874f4e5d4d63511f4c318fd39c36fab83322efbc.tar.bz2
perlweeklychallenge-club-874f4e5d4d63511f4c318fd39c36fab83322efbc.zip
Merge pull request #456 from Prajithp/master
challenge-019
Diffstat (limited to 'challenge-019')
-rw-r--r--challenge-019/prajith-p/perl5/ch01.pl16
-rw-r--r--challenge-019/prajith-p/perl5/ch02.pl28
2 files changed, 44 insertions, 0 deletions
diff --git a/challenge-019/prajith-p/perl5/ch01.pl b/challenge-019/prajith-p/perl5/ch01.pl
new file mode 100644
index 0000000000..ff01fdd2eb
--- /dev/null
+++ b/challenge-019/prajith-p/perl5/ch01.pl
@@ -0,0 +1,16 @@
+#!/opt/deployer/embedded/bin/perl -w
+
+use strict;
+use warnings;
+
+use DateTime;
+use feature qw<say>;
+
+for my $year (1900..2019) {
+ for my $month ( 1 , 3 , 5 , 7 , 8 , 10 , 12 ) {
+ my $dt = DateTime->new( year => $year , month => $month, day => 1);
+ if ( $dt->day_of_week == 5 ) {
+ say $dt->year . ' - ' . $dt->month_name;
+ }
+ }
+}
diff --git a/challenge-019/prajith-p/perl5/ch02.pl b/challenge-019/prajith-p/perl5/ch02.pl
new file mode 100644
index 0000000000..95b2787499
--- /dev/null
+++ b/challenge-019/prajith-p/perl5/ch02.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature qw<say>;
+
+my $text = q{
+Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
+};
+
+
+sub wrap {
+ my ($width, $text ) = @_;
+
+ my $ans = "";
+ my @text = split /\s+/, $text;
+ while(@text) {
+ my $line = shift(@text);
+ while ((@text) and (length($line) + length($text[0]) <= $width -1 )) {
+ $line .= ' ' . shift(@text);
+ }
+ $ans .= $line . "\n";
+ }
+
+ return $ans;
+}
+
+say wrap(30, $text);