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

Re: A possible solution for s?pintf

Thread Previous | Thread Next
Rod Adams
March 12, 2005 15:41
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/;
>This gives s?printf to any expression with short and concise syntax,
>making printf redundant, which means I won't even have to start a
>discussion about sayf :)
>    printf "%03d %15s", $foo, $bar;
>    print 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.
Why not just rename C< sprintf > to C< format > and ditch printf and sayf?

I will also remind you of the Scalar C< .as() >  method, which sprintf's 
it's value.

    print "$'%03d') $'%15s')";

But I'd still like to keep something works on a whole list at once for 
those cases where I'm doing several non-trivial expressions at once.

-- Rod Adams

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