Perl: the Markov chain saw | |
PerlMonks |
Re^4: Yesterday's dateby kcott (Archbishop) |
on May 30, 2023 at 07:48 UTC ( [id://11152498]=note: print w/replies, xml ) | Need Help?? |
G'day parv, hippo's code uses 86400. For those regularly working with dates and times, this might immediately leap out as the number of seconds in a day; for others, it might just be a cryptic number (which takes some thought to understand). Time::Seconds puts that number into a named constant. From its source:
I do believe that ONE_DAY is clearer than 86400. Even more so in this particular instance where "$t - ONE_DAY" aligns with the text in the following printf statement, "Date minus one day". I don't have a problem with "24 * 60 * 60". I would have used that calculation many times myself, over the decades, where ONE_DAY (or equivalent) was not available. It does, however, seem like extra, unecessary work:
Unless it's needed more than once, I probably wouldn't bother to "assign that to a local variable":
— Ken
In Section
Seekers of Perl Wisdom
|
|