Greetings Fellow Monks, and various other Clerics,
I've written a small script to parse through a directory of log files looking for a signature. The directory always has four files. I am searching for the signature in all files, then dumping the matching lines out to a file, called vpnwarn.out. What I need to do each time before hand is look to see if vpnwarn.out exists. If it does, I need to move it to vpnwarn.old and unlink vpnwarn.out. Then the script will run. Here's the pertinent parts of the script:
use strict;
use warnings;
use File::Copy "mv";
use Data::Dumper;
no strict 'refs';
my @names;
my $file;
my $name;
my $regex = 'WARNING';
#Variable to hold path to the log directory
my $dir = "H:/vpn/";
my $out = "H:/vpn/vpnwarn.out";
my $old = "H:/vpn/vpnwarn.old";
if (-s $out) {
mv ($out, $old)";
unlink ($out)";
}
What ends up happening is that the vpnwarn.out file grows and grows, along with the .old file. I'd originally tried to use Logfile::Rotate and Logfile::Cern, but neither would compile on Cygwin. I'm approaching this in this fashion so daily, we can have a diff report of the two files, seeing any new activity.
Short of help fixing either module for Cygwin, does anyone have any suggestions on how to clear the .out for overwriting?
Thanks,
Monger
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.