develooper Front page | perl.perl5.porters | Postings from September 2011

Re: [perl #100190] RFE: fix sprintf to be consistent with printf andbe useful!

Thread Previous | Thread Next
From:
Eric Brine
Date:
September 29, 2011 15:31
Subject:
Re: [perl #100190] RFE: fix sprintf to be consistent with printf andbe useful!
Message ID:
CALJW-qFgMXosN7ZW9YVySSqsW_vZKE3nZpAQzyO7xmaG_MES=Q@mail.gmail.com
On Wed, Sep 28, 2011 at 7:27 PM, Linda W <perl-diddler@tlinx.org> wrote:

> but expecting sprintf @arr to work would mean that open @arr should also
>> work, and so on; That road leads to madness.
>>
> open @arr would work?   Why?  It's NOT a simple list of scalers...
>

First, that's not true. C<open> only takes scalars for operands.

Secondly, you just answered your own question. What's special is the syntax.
c<printf> has a special syntax just like c<open>, which is why C<printf>
bhves different than C<sprintf>, C<substr>, C<length>, etc.


> It's first arg is something to be *written to*.


Actually, it's not. The first operand is a file handle. C<open> and
C<printf> write to the handle, but not to the first arg.

Even if it was being written to, you think you can write to one scalar, but
not $args[0] which is also a scalar?

  There is no special type in perl (that I'm aware of),
> call 'FORMAT STRING'....
>

That's eaxctly what sprintf is not special and printf is.

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