Tangentally related, I gave this program a go and the first separator
I tried was a space, but found that while other strings work, one or
more spaces doesn't. I tried -t and --t, with or without an equals
sign to no avail:

$ ./padded-cols.pl6 -t=" " padded.txt
Cannot invoke this object
  in block <unit> at ./padded-cols.pl6:9

The error is a bit cryptic. Any idea why it doesn't work and how space
might be allowed?

On 29 November 2015 at 05:42, Marc Chantreux <kha...@phear.org> wrote:
> On Sat, Nov 28, 2015 at 06:57:11PM +0100, Moritz Lenz wrote:
>> sub MAIN(*@*ARGS, Bool :$mean) { ... }
>
> damn it! i was so close! it will take me some time to understand that
> the positions of the parameters are completely revisited.
>
> so i mixed your answer and some interesting notes on lisibility by
> cognominal and finally get the following code.
>
> thanks a lot, perl6 hackers!
>
> #! env perl6
>
> sub padded-cols ($sep,@sheet) {
>     sub record-fmt( $col ) { "\%-{ [max] @sheet[*;$col].map: *.chars }s" };
>     my $fmt = @sheet[0].keys.map(&record-fmt).join: $sep;
>     @sheet.map: {$fmt.sprintf(|$_)}
> }
>
> sub MAIN (*@*ARGS,:$t) {
>     .say for padded-cols $t, $*ARGFILES.lines.map: (*.split($t)).eager;
> }
>
> --
> Marc Chantreux (eiro on github and freenode)
> http://eiro.github.com/
> http://eiro.github.com/atom.xml
> "Don't believe everything you read on the Internet"
>     -- Abraham Lincoln

Reply via email to