aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrajith Ndz <prajithpalakkuda@gmail.com>2019-08-02 14:40:03 +0530
committerPrajith Ndz <prajithpalakkuda@gmail.com>2019-08-02 14:40:03 +0530
commit688a12608e5a10e6a2577498eb286bf0b6b2988b (patch)
treead55c985d419a838d7269cf48e6647e62b03ef17
parent93619a25df3abe1c4084caa44d2fb015e0d367f4 (diff)
downloadperlweeklychallenge-club-688a12608e5a10e6a2577498eb286bf0b6b2988b.tar.gz
perlweeklychallenge-club-688a12608e5a10e6a2577498eb286bf0b6b2988b.tar.bz2
perlweeklychallenge-club-688a12608e5a10e6a2577498eb286bf0b6b2988b.zip
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);