strftime is an interface to a C function of the same name. It's a fairly common function in many applications that have to deal with dates and times. You may not need it here, but it's not a bad idea to get a little familiar with it. For the life of me, I can't ever remember all the format characters, so I wouldn't sweat those kinds of details. 'man strftime' provides you with easy access to a well-organized list on almost any UNIX-like OS.

I don't know which would be easier for your specific case, but I like to encourage people to look into all the options. Most of the format characters are intuitive, and there's some "shortcuts" to common formats. I use this function specifically for timestamps on log messages because its versatile, fast, and simple. Honestly. :)

Harry Putnam wrote:

"John W. Krahn" <[EMAIL PROTECTED]> writes:


You should probably be using POSIX::strftime instead which is simpler
and faster.

use POSIX 'strftime';

print FILE strftime( "An extra numeral <%D %T %w> appears\n",
localtime );

Probably coming off like some kind of carpy here but I'm puzzled by
this.

Its a nice tip and new material for me to use. But I don't really
see how its easier.

I'm guessing you say `easier' because its already written and all I
have to do is call it in and know the syntax.

Using this approach I'm required to remember the syntax for calling
strftime and the strftime operators when ever I need a specialized
date format. Even if its usually the same one I want.

I had in mind a dating subroutine I could call that gives a dating
string I prefer in most cases (for log lines etc). Without having to
remember date operators or other syntax. Just its name.

That is, I would look up the operators once. Put them in the
function and not ever think about them again.

To use the strftime example like that would require something similar
ie, writing a function that calls it in just the right way using
strftime, when ever needed. In that case it seems it would be about
par either way.

My knowledge of perl is not very deep so I may be missing other
obvious advantages. I mean besides the mentioned speed factor.





--
Benjamin J. Siders
Software Engineer



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to