#!/usr/bin/perl
#---------#---------#---------#---------#---------#---------#---------#---------
#
# title
#   rearrange date in each line
# author
#   idc@planetlarg.net 16 mar 04
# description
#   a datestamp i am using in a file is making things difficult when
#   I import into MS Excel
#
#   use like this
#     cat infile.log | this-script.pl > outfile.log
#
#   turn this line
#      [Mon Feb  6 15:01:00 GMT 2006]      bla bla bla...
#   into this
#      6 Feb 2006 15:01 bla bla bla...
#
# modifications
#
#---------#---------#---------#---------#---------#---------#---------#---------
# setup
#
#---------#---------#---------#---------#---------#---------#---------#---------
# main
#   read from STDIN
    while (<>) {
        next unless m/^\[/;  # skip lines with unexpected format
                             # ie. it does not start with a "["
        (
            $day,
            $mon,
            $date,
            $time,
            $timezone,
            $year,
            @rest
        ) = split;
        $year =~ s/(\d+)/$1/;                # remove trailing bracket
        $year = $1;
        $time =~ s/(\d+:\d\d):/$1/;          # remove seconds
        $time = $1;
        print "$date $mon $year $time @rest\n" ;

    }

#---------#---------#---------#---------#---------#---------#---------#---------
