diff options
| author | Yary Hluchan <yhluchan@apple.com> | 2020-08-04 12:16:11 -0400 |
|---|---|---|
| committer | Yary Hluchan <yhluchan@apple.com> | 2020-08-04 12:16:11 -0400 |
| commit | a12dfe4dcb319a1598d48cb05779a0f98dde783f (patch) | |
| tree | af781443276bb5dfcb468a13ead6eed8eabca2dd | |
| parent | 4a24622121e127e0d3fa75500ca5ceb5d8e7f71d (diff) | |
| download | perlweeklychallenge-club-a12dfe4dcb319a1598d48cb05779a0f98dde783f.tar.gz perlweeklychallenge-club-a12dfe4dcb319a1598d48cb05779a0f98dde783f.tar.bz2 perlweeklychallenge-club-a12dfe4dcb319a1598d48cb05779a0f98dde783f.zip | |
Better messages on bad inputs
| -rw-r--r-- | challenge-072/yary-h/range.raku | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/challenge-072/yary-h/range.raku b/challenge-072/yary-h/range.raku index b2caf65398..0b1abc61f4 100644 --- a/challenge-072/yary-h/range.raku +++ b/challenge-072/yary-h/range.raku @@ -8,11 +8,16 @@ # 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 +sub MAIN(Int $line_to_start is copy, #= First line to print + Int $end_line #= Last line to print + where { $_ >= $line_to_start + or die "end_line cannot be less than line_to_start" }, + + *@input_file #= File(s) to read from. Also reads STDIN. + where { .all.IO.f + or die "Not a file path:\n { .grep({! .IO.f}).join: "\n " } "} + ) { + .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 } |
