Another common pattern is to create a routine that behaves like Perl's sprintf, but with a different set of conversion routines. (It will also almost certainly have much simpler semantics than Perl's wildly complex behavior.)

Some objects provide methods to stringify them flexibly. For example, many objects that represent timestamps allow you to call strftime or something similar. The method_replace string replacer comes in handy here: