diff options
| author | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2020-08-03 10:45:27 +0200 |
|---|---|---|
| committer | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2020-08-04 18:37:12 +0200 |
| commit | 77ecfbb261970d6becc0874f75fefc92a9c0af4d (patch) | |
| tree | 333f743d42870dbcb5256da5fe788f2d91b5ba9c | |
| parent | f0b64ff0e70eb4b92fe25556d254a944200670b0 (diff) | |
| download | perlweeklychallenge-club-77ecfbb261970d6becc0874f75fefc92a9c0af4d.tar.gz perlweeklychallenge-club-77ecfbb261970d6becc0874f75fefc92a9c0af4d.tar.bz2 perlweeklychallenge-club-77ecfbb261970d6becc0874f75fefc92a9c0af4d.zip | |
solution for task 2
| -rw-r--r-- | challenge-072/jo-37/perl/ch-2.in | 8 | ||||
| -rwxr-xr-x | challenge-072/jo-37/perl/ch-2.pl | 21 |
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-072/jo-37/perl/ch-2.in b/challenge-072/jo-37/perl/ch-2.in new file mode 100644 index 0000000000..a694c02976 --- /dev/null +++ b/challenge-072/jo-37/perl/ch-2.in @@ -0,0 +1,8 @@ +L1 +L2 +L3 +L4 +L5 +L6 +L7 +L8 diff --git a/challenge-072/jo-37/perl/ch-2.pl b/challenge-072/jo-37/perl/ch-2.pl new file mode 100755 index 0000000000..423ed6ca80 --- /dev/null +++ b/challenge-072/jo-37/perl/ch-2.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +sub print_range { + my ($file, $A, $B) = (shift, shift() + 0, shift() + 0); + + return if !$file || $A < 1 || $B < $A; + + open my $fh, '<', $file or die "$file: $!\n"; + eval <<EOS; + while (<\$fh>) { + print if $A .. $B; + } +EOS + die $@ if $@; + close $fh or warn "$file: $!\n"; +} + +print_range 'ch-2.in', 3, 5; |
