You could probably do it with something like this.

my %month = (
        Jan     => '01',
        Feb     => '02',
        Mar     => '03',
        Apr     => '04',
        May     => '05',
        Jun     => '06',
        Jul     => '07',
        Aug     => '08',
        Sep     => '09',
        Oct     => '10',
        Nov     => '11',
        Dec     => '12',
        );      # Be sure to quote the numbers, because they have to be
                # evaluated as a string, otherwise perl will remove the
                # leading zero.

open( LOG, "/path/to/logfile" ) or die "Cannot open log file: $!";
flock LOG, 2;
while(<LOG>) {
        # search string for match. If found print with new format
        if( /(\w{3}) (\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})/ ) {
                print "$6 $month{$1} $2 $3 $4 $5\n";
        }
}

close( LOG ) or die "Cannot close log file: $!";


I hope that gets you on the right track.

Comments or suggestions are welcome.

Joshua Colson
Systems Administrator
Giant Industries, Inc.
(480) 585-8714
[EMAIL PROTECTED]


-----Original Message-----
From: Busse, Rich [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 08, 2002 11:09 AM
To: Perl Beginners
Subject: Data conversion


I'm working with some log file entries that look like:

BDE Monitor End - Wed Jan 30 08:36:28 2002

I need to turn the time stamp part of it into:

2002 01 30 08 36 28

Are there modules available for this type of conversion? Would Date::Manip
be a good choice?

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

Reply via email to