#!/use/local/bin/perl -w use strict; use IO::File; use Getopt::Long; # Parse command line arguments and assign corresponding variables GetOptions ( 'i|input=s' => \( my $INPUT = undef ), 'o|output=s' => \( my $OUTPUT = "./data-in,./data-out" ), 'g|graph=s' => \( my $GRAPH = "./graph" ), ); unless ( defined $INPUT ) { print <) { # for each line in the input file next if /^\s*$/; # ignore empty lines my @col = split /,\s+/; # split on , followed by spaces my ($date) = $col[0] =~ /^"(.*)\s.*"$/; # want date only print $di "$date, $col[2]\n"; print $do "$date, $col[3]\n"; } undef $di; # force close of files undef $do; undef $f; # do the graph system($GRAPH) or die "Could not execute $GRAPH"; exit(0); __END__ example: ./script.pl -i snmp.log