ExReg has asked for the wisdom of the Perl Monks concerning the following question:
Just seeking enlightenment here. Already can get it to do what I want, but... I was typing in a few things to get them in the exact format I wanted when I ran into a peculiarity. When I enter
perl -e '($s,$m,$h,$md,$mo,$y,$w,$g,$i)=localtime;print $y+1900 . "." . ($mo+1) . ".$md." . ($h-5) . "$m\n";'I get 2019.8.1.19.47. (I hope I transcribed the above correctly)
But if I type
perl -e '($s,$m,$h,$md,$mo,$y,$w,$g,$i)=localtime;print $y+1900 . "." . $mo+1 . ".$md." . ($h-5) . "$m\n";'I get 2020.7.1.19.47. The +1 after $mo now gets applied to $y instead. The same is true for the parentheses around $h. I am trying to wrap my feeble mind around this one. What is going on?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Where did all the time go?
by choroba (Cardinal) on Aug 01, 2019 at 20:20 UTC | |
by ExReg (Priest) on Aug 01, 2019 at 20:29 UTC | |
|
Re: Where did all the time go?
by Fletch (Bishop) on Aug 01, 2019 at 20:20 UTC | |
by haukex (Archbishop) on Aug 01, 2019 at 20:32 UTC |