#!/usr/bin/env perl -w #This is a sample script. Please test it thoroughly before using it on a production server. use strict; my $argc = @ARGV; if ($argc != 2) { die("Usage: getInfo.pl \n"); } my @output_files = qw/error.txt user_count.txt/; foreach my $output_file (@output_files) { if( -f $output_file) { unlink $output_file; } } open(INPUT, "< $ARGV[0]"); open(OUTPUT, "> ./error.txt"); open(OUTPUT2, "> ./user_count.txt"); my $error = 0; #boolean value my $user_count = 0; my $count_server_error = 0; while() { chomp; if(/^Perforce server error.*$/) { $error = 1; $count_server_error++; } elsif(/^Perforce server info.*$/) { $error = 0; } elsif(/^.*\s$ARGV[1]\@.*$/) { print OUTPUT2 "$_\n"; $user_count++; } if($error == 1) { print OUTPUT "$_\n"; } } print OUTPUT "The count of " . $ARGV[1] . " actions on the database: " . $user_count . "\n"; print OUTPUT "The count of Perforce server error: " . $count_server_error; print "The count of " . $ARGV[1] . " actions on the database: " . $user_count . "\n"; print "The count of Perforce server error: " . $count_server_error . "\n"; close(INPUT); close(OUTPUT); close(OUTPUT2);