diff options
| -rw-r--r-- | challenge-019/simon-proctor/perl6/ch-2.p6 | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-019/simon-proctor/perl6/ch-2.p6 b/challenge-019/simon-proctor/perl6/ch-2.p6 new file mode 100644 index 0000000000..e0bb089dde --- /dev/null +++ b/challenge-019/simon-proctor/perl6/ch-2.p6 @@ -0,0 +1,27 @@ +#!/usr/bin/env perl6 + +use v6; + + + +#| Read from STDIN and wrap to the given number of characters +multi sub MAIN ( + UInt() $width = 80, #= Width to wrap to (default 80 characters) +) { + my $out = ""; + my $left = $width; + for $*IN.words -> $word { + if $word.codes + 1 > $left { + say $out; + $out = ""; + $left = $width; + } + $out = $out ?? "$out $word" !! $word; + $left = $width - $out.codes; + } + say $out if $out; +} + + +#| Display help +multi sub MAIN( Bool :h(:$help) where ?* ) { say $*USAGE } |
