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

Re: A possible solution for s?pintf

Thread Previous | Thread Next
Brent 'Dax' Royal-Gordon
March 12, 2005 15:51
Re: A possible solution for s?pintf
Message ID:
Juerd <> wrote:
> Without introduction, I'll just present the syntax idea:
>     f/%03d %15s/$foo, $bar/;
> Of course, this is s///-like in quoting behaviour, so f[][] or f"""
> should work just as well. The RHS is not a string, but parsed as an
> expression in list context. If this feels weird, just think of s///e,
> where the RHS is also not a string.

I think s///e is going away, since you can just use s/pattern/{code}/
now anyway.

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');

Or, if that's not quite sufficient:

    say map { }
        $num => '%d',
        $str => '%s',

Brent 'Dax' Royal-Gordon <>
Perl and Parrot hacker

"I used to have a life, but I liked mail-reading so much better."

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About