develooper Front page | perl.perl6.language | Postings from March 2005

Re: A possible solution for s?pintf

Thread Previous | Thread Next
From:
Matt Diephouse
Date:
March 12, 2005 20:08
Subject:
Re: A possible solution for s?pintf
Message ID:
198c87380503122001464c985d@mail.gmail.com
Brent 'Dax' Royal-Gordon <brentdax@gmail.com> wrote:
> Besides, I think "as" will do just fine, especially since you can now
> interpolate method calls as well.  You can even do something like this
> if you want to perform bulk formatting:
> 
>     say join ' ', ($n1, $n2, $n3) >>.as('%d');

What about:

  say [ $n1, $n2, $n3 >>.as('%d') ].join;

?

Can I (1) use join on a bracketed list and (2) leave off the
parentheses around C<$n1, $n2, $n3>? (I couldn't find where hyper ops
are on the precedence table.)

> Or, if that's not quite sufficient:
> 
>     say map { .key.as(.value) }
>         $num => '%d',
>         $str => '%s',
>         ...;

And this:

  say [ $num => '%d', $str => '%s' ] >>.key.as(.value);

?

Can I (3) hyper-op chained method calls and (4) use square brackets in
this instance (to make sure my list doesn't form a parameter list to
C<say>)?

-- 
matt diephouse
http://matt.diephouse.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About