aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYary Hluchan <yhluchan@apple.com>2020-08-03 14:41:37 -0400
committerYary Hluchan <yhluchan@apple.com>2020-08-03 14:41:37 -0400
commit723afc9a452054a0928d4b916fb94cb7695a545a (patch)
tree52408686a705f50e9dc7f4f7ff1efb84c722f98e
parent25365364c03d323564aad1593e3a769fb3815d09 (diff)
downloadperlweeklychallenge-club-723afc9a452054a0928d4b916fb94cb7695a545a.tar.gz
perlweeklychallenge-club-723afc9a452054a0928d4b916fb94cb7695a545a.tar.bz2
perlweeklychallenge-club-723afc9a452054a0928d4b916fb94cb7695a545a.zip
Solution for line-range puzzle, Classic Perl
-rw-r--r--challenge-072/yary-h/input.txt12
-rw-r--r--challenge-072/yary-h/range.pl14
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-072/yary-h/input.txt b/challenge-072/yary-h/input.txt
new file mode 100644
index 0000000000..756958ea91
--- /dev/null
+++ b/challenge-072/yary-h/input.txt
@@ -0,0 +1,12 @@
+L1
+L2
+L3
+L4
+L5
+L6
+L7
+L8
+L9
+L10
+L11
+L12
diff --git a/challenge-072/yary-h/range.pl b/challenge-072/yary-h/range.pl
new file mode 100644
index 0000000000..204bd2255c
--- /dev/null
+++ b/challenge-072/yary-h/range.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+# Run as:
+# range.pl 4 10 < input.txt
+# or
+# range.pl 4 10 input.txt
+
+my ($begin_line, $end_line)=splice @ARGV,0,2;
+
+# Not using flip-flop .. want to simply exit on the end line
+while (<>) {
+ next if $. < $begin_line;
+ print;
+ exit if $. >=$end_line;
+}