#!/usr/bin/perl -w use Text::ParseWords; use strict; my $log = "pixlog"; my $looptime = 300; my $maxsize = 1000; my (@lines, @fields); my ($month, $monthstring, $item, $x); while (1) { my $newlog = `date '+%d%m%Y%H%M%S.fakepix'`; open (LOGFILE, "< $log") || die "Could not open file: $! \n"; @lines = ; close (LOGFILE); open (NEWLOG, ">$newlog"); monthstring(); foreach $item (@lines) { @fields = quotewords(' ',0,$item); my $time1 = `date '+%H:%M:%S'`; chop $time1; my $time2 = `date '+%H:%M:%S:'`; chop $time2; my $date = `date '+%d'`; chop $date; my $year = `date '+%Y'`; chop $year; if ($fields[7] =~ (m/:\d+\d+:\d+\d+:/)) { $fields[0] = $monthstring; $fields[1] = $date; $fields[2] = $time1; $fields[4] = $monthstring; $fields[5] = $date; $fields[6] = $year; $fields[7] = $time2; } else { $fields[0] = $monthstring; $fields[1] = $date; $fields[2] = $time1; } for ($x=0; $x <= $#fields; $x++) { if ($x eq $#fields) { print NEWLOG "$fields[$x]"; } else { print NEWLOG "$fields[$x]"; print NEWLOG " "; } } } close (NEWLOG); sub monthstring { $month = `date '+%m'`; if ($month =~ /01/) { $monthstring = "Jan"; return $monthstring; } if ($month =~ /02/) { $monthstring = "Feb"; return $monthstring; } if ($month =~ /03/) { $monthstring = "Mar"; return $monthstring; } if ($month =~ /04/) { $monthstring = "Apr"; return $monthstring; } if ($month =~ /05/) { $monthstring = "May"; return $monthstring; } if ($month =~ /06/) { $monthstring = "Jun"; return $monthstring; } if ($month =~ /07/) { $monthstring = "Jul"; return $monthstring; } if ($month =~ /08/) { $monthstring = "Aug"; return $monthstring; } if ($month =~ /09/) { $monthstring = "Sep"; return $monthstring; } if ($month =~ /10/) { $monthstring = "Oct"; return $monthstring; } if ($month =~ /11/) { $monthstring = "Nov"; return $monthstring; } if ($month =~ /12/) { $monthstring = "Dec"; return $monthstring; } } sleep($looptime) }