use POSIX qw(strftime); my $time = POSIX::strftime( "%T", localtime) #### my $msg = substr( $msg, 0, 50 ) . '-' if 50 < length $msg;