2xlp has asked for the wisdom of the Perl Monks concerning the following question:
python's sprintf is really neat.
you can use placeholders like perl hello = "Hello %s!" % $name
or with name placeholders, like in a database query hello = """Hello %(name)s""" % { 'name': name }
in all my years of perl , i've never seen named placeholders like this. that could be more my exposure/eduction than anything else though -- does anyone know a way to achieve/emulate this behavior (without, of course, writing my own regex function/module or using many cpan libraries)?
you can use placeholders like perl hello = "Hello %s!" % $name
or with name placeholders, like in a database query hello = """Hello %(name)s""" % { 'name': name }
in all my years of perl , i've never seen named placeholders like this. that could be more my exposure/eduction than anything else though -- does anyone know a way to achieve/emulate this behavior (without, of course, writing my own regex function/module or using many cpan libraries)?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: python like named placeholders sprintf ?
by runrig (Abbot) on Jan 15, 2009 at 00:06 UTC | |
Re: python like named placeholders sprintf ?
by ikegami (Patriarch) on Jan 14, 2009 at 23:47 UTC | |
Re: python like named placeholders sprintf ?
by jdporter (Paladin) on Jan 15, 2009 at 01:45 UTC | |
Re: python like named placeholders sprintf ?
by haoess (Curate) on Jan 15, 2009 at 08:33 UTC | |
Re: python like named placeholders sprintf ?
by jeffa (Bishop) on Jan 15, 2009 at 18:20 UTC | |
by saberworks (Curate) on Jan 16, 2009 at 03:25 UTC | |
Re: python like named placeholders sprintf ?
by 2xlp (Sexton) on Jan 15, 2009 at 20:26 UTC | |
by Anonymous Monk on Jan 18, 2009 at 06:22 UTC | |
by Anonymous Monk on Jan 23, 2009 at 10:16 UTC | |
Re: python like named placeholders sprintf ?
by Jenda (Abbot) on Jan 15, 2009 at 22:24 UTC |
Back to
Seekers of Perl Wisdom