develooper Front page | perl.perl6.language | Postings from July 2006

Re: sprintf and snake envy

Thread Previous | Thread Next
From:
Larry Wall
Date:
July 4, 2006 09:37
Subject:
Re: sprintf and snake envy
Message ID:
20060704163720.GB8942@wall.org
On Tue, Jul 04, 2006 at 05:27:33PM +0100, Nicholas Clark wrote:
: I'm not convinced that sprintf needs an operator. It's not commonly used in
: any code I've looked at, which to me suggests that it's not good huffman
: coding to use up a terse symbol for it, denying that symbol to something
: else.

Well, we kinda do have an operator already, if you consider infix:<as> to
be a variant of .as().

    $c as '%03d'
    $c.as('%03d')

but it's arguable which is better in a string:

    $a = "{$c as '%03d'}"
    $a = "$c.as('%03d')"

But that's backwards from Python's % operator.  Actually, I think I like
the Perl way better for single patterns...  :)

Larry

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