in reply to Difference of localtime
Depends on what you mean by "code any different?".
In case you want to know if the internally generated opcodes are the same,
you can use perl -MO=Concise ... to show them (see B::Concise).
In this case you'd see that the code is different, i.e. scalar is
still there (not optimised away, Update: see ysth's note) in the one case, despite being redundant, and time is being
called explicitly in the other case, despite being the default with localtime anyway:
... 2 <;> nextstate(main 1 745882.pl:4) v ->3 6 <2> sassign vKS/2 ->7 4 <1> localtime[t3] sK/1 ->5 3 <0> time[t2] s ->4 5 <0> padsv[$now:1,2] sRM*/LVINTRO ->6 7 <;> nextstate(main 2 745882.pl:5) v ->8 ... vs. ... 2 <;> nextstate(main 1 745882.pl:7) v ->3 5 <2> sassign vKS/2 ->6 - <1> scalar sK/1 ->4 3 <0> localtime[t2] s ->4 4 <0> padsv[$re:1,2] sRM*/LVINTRO ->5 6 <;> nextstate(main 2 745882.pl:8) v ->7 ...
That said, the code will produce the same output... (if you happen to execute both statements immediately one after another, and unless you happen to pass a seconds boundary in between the two calls).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Difference of localtime
by ysth (Canon) on Feb 24, 2009 at 05:06 UTC | |
|
Re^2: Difference of localtime
by ikegami (Patriarch) on Feb 24, 2009 at 06:59 UTC |