in reply to parsing etime field from solaris ps

I think a regex makes more sense in this case. Yours can be cleaned up a bit though.

my ($dd,$hh,$mm,$ss) = /^(?:(\d\d)-)?(?:(\d\d):)?(\d\d):(\d\d)$/;
-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: parsing etime field from solaris ps
by greenFox (Vicar) on May 30, 2003 at 04:58 UTC

    I can't believe I wrote {0,1} :) Your clean up is not quite right though- probably because I didn't give enough information to start with. $dd is not zero padded and whilst the man page says $mm is zero padded (on solaris 8 at least) it isn't zero padded when the etime is less than an hour.

    /^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/;

    which is way better than what I had, thanks.

    --
    Life is a tale told by an idiot -- full of sound and fury, signifying nothing. William Shakespeare, Macbeth