TIP: Click on subject to list as thread! ANSI
echo: perl
to: Maurice Kinal
from: tony summerfelt
date: 2005-02-23 18:54:22
subject: posix strftime

# On Tue, Feb 22/05 at 01:35 PM, Maurice Kinal wrote to Johan Billing:

 MK> Yeppers, the POSIX module is a handy, dandy tool to have onboard.  I
 MK> think it's a keeper.

i've been using the posix module for a max style logging routine for ages...

=================================================================
use POSIX qw(strftime);

$newsession=1;
$log="test.log";

sub logmsg #{{{
{
    $stime= strftime("%d %b %H:%M:%S -- ", localtime(time));
    $_="{at}_";
    if  (/^[\+\:\-\?\!\$\#]/)
    {
        $prefix= "$& "; $msg=$'; $msg=~s/^\s+//;
    } else {
        $prefix= "  "; $msg=$_;
    }
    $msg="$prefix".$stime.$msg;
    open elog, ">>$log" || die "can't open $log - $!";
    print elog "\n" if $newsession;
    $newsession=0   if $newsession;
    print elog "$msg\n";
    close elog;
} #}}}

logmsg("! errog msg");
logmsg("? warning msg);
logmsg("testing blank");

.t

... telnet://ventedspleen.dyndns.org
--- GoldED/spleen 3.0.1+
* Origin: ventedspleen.dyndns.org (1:249/100)
SEEN-BY: 633/267 270
@PATH: 249/100 261/38 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.