nemesdani has asked for the wisdom of the Perl Monks concerning the following question:
There is a sub getLocalTime, quite self-explanatory:$commonConfig_tmp->{ 'DAY' } = ${configContainer->getLocalTime}[3] +; $commonConfig_tmp->{ 'MONTH' } = ${configContainer->getLocalTime}[ +4]; $commonConfig_tmp->{ 'YEAR' } = ${configContainer->getLocalTime}[5 +];
Now my question is: in the constructor getLocalTime, thus localtime() is called 3 times. I see this as unnecessary, I could assign the values with 1 call. Or am I missing someting concerning objects / constructors? Thank you for your help.sub getLocalTime { my @timeData = localtime(time); @timeData[5] += 1900; @timeData[4] += 1; return \@timeData;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Redundant function calls in constructor?
by GrandFather (Saint) on Apr 02, 2012 at 10:00 UTC | |
|
Re: Redundant function calls in constructor?
by tinita (Parson) on Apr 02, 2012 at 10:30 UTC | |
by nemesdani (Friar) on Apr 02, 2012 at 12:23 UTC | |
by AnomalousMonk (Archbishop) on Apr 02, 2012 at 14:28 UTC | |
by nemesdani (Friar) on Apr 02, 2012 at 17:29 UTC | |
|
Re: Redundant function calls in constructor?
by roboticus (Chancellor) on Apr 02, 2012 at 10:01 UTC | |
|
Re: Redundant function calls in constructor?
by nemesdani (Friar) on Apr 02, 2012 at 10:14 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |