-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 20 Apr 2007, at 20:23, Paul LeoNerd Evans wrote:
An interesting idea, but what does that buy you that a plain sprintf does
not?

  $pr->build( { ALBUM => sprintf("%04d", $album),
                PHOTO => sprintf("%04d", $photo) } )

It encapsulates the formatting requirement where it belongs - with the rest of the specification for that string.

In this example with numbers as the keys perhaps it looks useful, but
isn't that a special case? In most cases, we couldn't do anything special
like zero-pad the numbers.

For example, if we had users in groups:

 '/groups/${GROUP:\w+}/users/${USER:\w+}.html'

There's no other printf format of any interest that comes to mind, other
than %s.

I agree that it's not massively general - but you could use it to

* generate fixed width fields
* truncate reals to ints
* specify the number of decimal places

- --
Andy Armstrong, hexten.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFGKSH6woknRJZQnCERAntiAJ9lOXcex7gPF3uaPO3g/ef+r+mDugCfVELw
rvH+S5m1iEaDSEt+YTRl52k=
=96dn
-----END PGP SIGNATURE-----

Reply via email to