laziness, impatience, and hubris | |
PerlMonks |
Re^3: substitution with regexby Athanasius (Archbishop) |
on Jan 23, 2018 at 06:46 UTC ( [id://1207730]=note: print w/replies, xml ) | Need Help?? |
Hello drose2211, The sprintf function applies the formatting specified in the template supplied as its first argument, to produce a string using the remaining arguments. In this case, the template ' %d/%d ' means: print a space, followed by the next argument formatted as an integer, followed by a slash, followed by the next argument formatted as an integer, followed by a space. Without the sprintf function, the code would be longer and less elegant:
(Perl’s printf and sprintf functions are derived from their equivalents in C. In Perl, there is also print, which does not take a template, but there is no corresponding sprint.) Hope that helps,
In Section
Seekers of Perl Wisdom
|
|