diff options
| author | Yary Hluchan <yhluchan@apple.com> | 2020-08-03 15:56:38 -0400 |
|---|---|---|
| committer | Yary Hluchan <yhluchan@apple.com> | 2020-08-03 15:56:38 -0400 |
| commit | 3c03c2c370d6545f78384a8545183e7749ae7be6 (patch) | |
| tree | 1b87b0b71541fa1b57edf5601eb56c1ed49b9ff5 /challenge-072 | |
| parent | 723afc9a452054a0928d4b916fb94cb7695a545a (diff) | |
| download | perlweeklychallenge-club-3c03c2c370d6545f78384a8545183e7749ae7be6.tar.gz perlweeklychallenge-club-3c03c2c370d6545f78384a8545183e7749ae7be6.tar.bz2 perlweeklychallenge-club-3c03c2c370d6545f78384a8545183e7749ae7be6.zip | |
add Raku solution, and alternative Perl solution
Diffstat (limited to 'challenge-072')
| -rw-r--r-- | challenge-072/yary-h/range.raku | 18 | ||||
| -rw-r--r-- | challenge-072/yary-h/range_ff.pl | 14 |
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-072/yary-h/range.raku b/challenge-072/yary-h/range.raku new file mode 100644 index 0000000000..cd36987cae --- /dev/null +++ b/challenge-072/yary-h/range.raku @@ -0,0 +1,18 @@ +#!/usr/bin/env raku + +# Run as: +# range.pl 4 10 < input.txt +# or +# range.pl 4 10 input.txt + +# Playing with command-line validation. +# Lines are ints, end_line is greater than begin_line, +# all input files are readable- OK to skip that, CatHandle would complain. +sub MAIN(Int $line_to_start is copy, #= First line to print + Int $end_line where * >= $line_to_start, #= Last line to print + *@input_file where (*.all).IO.f #= File(s) to read from. Also reads STDIN. + ) { + .say if --$line_to_start < 1 + for IO::CatHandle.new(@input_file, $*IN).lines($end_line) + # Alternative would be to use .lines.kv to get line num with line +} diff --git a/challenge-072/yary-h/range_ff.pl b/challenge-072/yary-h/range_ff.pl new file mode 100644 index 0000000000..e500112dc2 --- /dev/null +++ b/challenge-072/yary-h/range_ff.pl @@ -0,0 +1,14 @@ +#!/usr/bin/env perl -n + +# Run as: +# range.pl 4 10 < input.txt +# or +# range.pl 4 10 input.txt + +# This version abuses command-line option in shebang, +# and also the flip-flop + +our ($begin_line, $end_line); +BEGIN { ($begin_line, $end_line)=splice @ARGV,0,2 }; + +$. == $begin_line .. print, $. >= $end_line && exit |
