Re:Why Did I Choose Perl When Building Crowdtilt?
by ionforce on Friday August 31, 2012 @08:03PM
(#4462205)
In Perl you could write
print "I ate a $fruit for $meal"
Or
printf 'I ate a %s for %s', $fruit, $meal
Re:Why Did I Choose Perl When Building Crowdtilt?
by e12e on Saturday September 01, 2012 @07:31AM
(#4463424)
"This is %(adjective)s readable Python in %(genetive)s opinion" % {"adjective":"more", "genetive":"my"}
> 'This is more readable Python in my opinion'
edit: variable names
Also, I agree that for this simple case, perl (and other's) simple dollar substitution is nicer.
But since you called-out Python and Ruby, I'm curious what you meant.
In Python, for example, interpolation would look like:
print "I ate a %s for %s" % ('banana', 'lunch)
(or the newer way with nominally more keystrokes)
print "I ate a {0} for {1}".format('banana', 'lunch')
I've done plenty of PHP work and I get that I can do "{$varhere}" but for strings of any length or complexity it was totally common to use sprintf() an I have to assume the same readability principles apply in Perl?