Time::Piece and localtime in list context

TeeJay on 2006-03-13T12:00:14

I just spent 2 hours chasing down this bug..

I just found the cause of my problems (with the help of Hook::LexWrap) - I was calling localtime in list context, and it was returning the first of the list of values instead of the Time::Piece object I was expecting hundreds of lines and 30 seconds or two minutes away from the source of the problem.

Checking the documentation it doesn't mention this behaviour - I can understand why, but it's still unexpected.. ah - just found it.. there is a very brief mention that it over-rides scalar context.. maybe a bigger warning would be nicer.. unsure wether it's worth mentioning in annocpan or rt.


Patches welcome :-)

Matts on 2006-03-13T15:45:16

The idea was that you could have a program where you loaded Time::Piece and it wouldn't matter how you used it, it would be natural. I guess I can't account for programmer error :-)

Re:Patches welcome :-)

TeeJay on 2006-03-13T16:24:45

Can you just put a note writ large to remind baffled hackers that in a list context you'll get a list rather than an object?

I know it's kind of mentioned, but a big noticable reminder would probably save dumb programmers a lot of time.. It's always the silly mistakes that eat most time. *sigh*