Conflict And Error Report Perl Scrip Developed by the UIC Library Questions: contact Kristin Martin at kmarti@uic.edu or Kavita Mundle at kavita@uic.edu. The program compares the results of the archive files Cat Job 5-7, which are run every week. The archive files are recorded by Voyager reporter in: C:\Voyager\Reporter\Reports It's a very basic perl program that compares the old file to the new file and lists the new lines. The only problem they might have is that they have:

helmetpastoralSoftware and s/w Development

Dec 13, 2013 (3 years and 8 months ago)

99 views


UIC Library Authority perl script


August 3, 2010



Page
1


Conflict And Error Report Perl Scrip Developed by the UIC Library

Questions: contact Kristin Martin at kmarti@uic.edu or Kavita Mundle at kavita@uic.edu.


The program compares the results of the archive files Cat Job 5
-
7, which are run every week.
The arc
hive files are recorded by Voyager reporter in: C:
\
Voyager
\
Reporter
\
Reports


It's a very basic perl program that compares the old file to the new file and lists the new lines.
The only problem they might have is that they have:

1. Perl installed,

2. A ne
w folder called "My Reports" in the Reporter folder

3. The path to notepad.exe which is specified in the program and would have to be changed if it
is in a different place.


Full script is below:


#/usr/bin/perl
-
w


@report = ();

$count=0;

print "Enter t
he report name that was created last week:
\
n";

chomp($oldrept = <STDIN>);


print "Enter the report name that was created today:
\
n";

chomp($newrept = <STDIN>);

open(INFILE, "c:
\
\
Voyager
\
\
Reporter
\
\
Reports
\
\
$newrept") or die "Can't find newfile
\
n";

# read ne
w report first to load up hash

# will get all new errors.

while (<INFILE>) {

# reads a line each time until eof


@report = split /
\
|/; # SPLITS THE CURRENT LINE FROM INFILE


if ($report[0] eq "05" or



$report[0] eq "06" or



$report[0] eq "07")



{

# Check FIRST SEGMENT OF ARRAY


UIC Library Authority perl script


August 3, 2010



Page
2




$count++;



$key = $_; # key is entire line



if (exists $in_hash{$key}) {




print "duplicate key $key found
\
n";




}



$in_hash{$key}=$_; #value is entire line





}





}

#print "number of records from new report $cou
nt
\
n";

close INFILE;


@report2 = ();

$count2=0;

open(INFILE2, "c:
\
\
Voyager
\
\
Reporter
\
\
Reports
\
\
$oldrept") or die "Can't find oldfile
\
n";

#open(OUTDUP, ">d:
\
\
Reports
\
\
outdup") or die "can't open outdup
\
n";

while (<INFILE2>) {

# reads a line each time until

eof


@report2 = split /
\
|/; # SPLITS THE CURRENT LINE FROM INFILE



if ($report2[0] eq "05" or



$report2[0] eq "06" or



$report2[0] eq "07")



{ # Check FIRST SEGMENT OF ARRAY



$count2++;



$key2 = $_; # key is entire line



if (exists $in_hash{
$key2}) {




#print OUTDUP $key2;




$cntdup++;




undef $in_hash{$key2}; #delete dup line from hash




}



#else {$in_hash{$key2}=$_;} # value is entire non dup line


UIC Library Authority perl script


August 3, 2010



Page
3



# don't want to put the old report lines in, even if they


# are not dups. Already saw
them in last weeks report.


}




}

#print "number of records from old report $count2
\
n";

#print "number of records that are duplicate $cntdup
\
n";


close INFILE2;

open(REPORT, ">c:
\
\
Voyager
\
\
Reporter
\
\
My Reports
\
\
newrept") or die "can't open newrept
\
n";


f
oreach $key (sort {$in_hash{$a} cmp $in_hash{$b}} keys %in_hash) {


print REPORT $in_hash{$key};


if (defined $in_hash{$key}) {$count3++;} # there is a value

}

#print "number of records in report created: $count3
\
n";

#print "Report Complete
\
n";

#print "Pr
ess Enter to close window";

#$wait=<STDIN>;


use Win32::Process;


my $command = "c:
\
\
Windows
\
\
Notepad.exe";

my $args = "Notepad.exe c:
\
\
Voyager
\
\
Reporter
\
\
My Reports
\
\
newrept";

my $proc;


Win32::Process::Create($process, $command, $args, 0,


DETACHED_PROCE
SS,'.');