in reply to Using split, splice, and join to remove time from scalar context return of localtime()

How about:

[0] Perl> $now = substr localtime(), 11, 8;; [0] Perl> print $now;; 21:59:52

Should be way faster than either of the other methods. It's method a in these results:

Rate b c a b 121/s -- -37% -70% c 191/s 58% -- -53% a 405/s 235% 112% --

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"
  • Comment on Re: Using split, splice, and join to remove time from scalar context return of localtime()
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Using split, splice, and join to remove time from scalar context return of localtime()
by ikegami (Patriarch) on Dec 17, 2009 at 22:34 UTC
    Without any use locale, does localtime use the current locale?

      I've no idea. To either the question or it's relevance.

      But if it doesn't, I'd say that was a bug in Perl or the pragma.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Your solution requires localtime to return strings with specific arrangement of characters. If localtime returns a string based on the locale, your solution could break.

        I don't know how to change locale to test.