Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

TeeJay (2309)

  (email not shown publicly)

Working in Truro
Graduate with BSc (Hons) in Computer Systems and Networks
pm :,,
lug : Devon & Cornwall LUG
irc : TeeJay
skype : hashbangperl
livejournal : hashbangperl []
flickr :hashbangperl []

Journal of TeeJay (2309)

Monday March 13, 2006
07:00 AM

Time::Piece and localtime in list context

[ #28976 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • 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 :-)
    • 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*

      @JAPH = qw(Hacker Perl Another Just);
      print reverse @JAPH;