Well here is the entire code it is rather long. It just says syntax
error on line 55 near $user1
#!/usr/bin/perl
use Tie::File;
use Switch;
sub trimwhitespace($);
sub nslookup();
$debug = 0;
chdir("/usr/local/home/autosys/seos_autotrack");
$auditrecords = 0;
$n = 0;
$srecords = 0;
$arecords = 0;
$index = 0;
$totalmatched = 0;
$totalunmatched = 0;
my @monthnames = (qw(dummy Jan Feb Mar Apr May Jun Jul Aug Sep Nov Dec));
open FILEREAD, "<seos_autotrack_day";
$runday = <FILEREAD>;
close FILEREAD;
$logfilename = "autotrack-seos-compare".$runday.".log";
use Fcntl 'O_RDWR', 'O_CREAT';
my $o = tie @logfile, 'Tie::File', $logfilename, mode => O_RDWR |
O_CREAT, dw_size => 512;
$logrecords = @logfile;
if ($logrecords > 0) {splice @logfile, 0, $logrecords;}
$o->STORE($n, "Debug mode set to: ".$debug);
open FILEREAD, "<seos_autotrack_date";
$rundate = <FILEREAD>;
close FILEREAD;
tie @servers, 'Tie::File', 'servers' || die "Can't open: $!\n";
foreach $server (@servers)
{
$iplist = nslookup($server, 'Address');
$serverlist{$iplist} = sprintf "%s",$server;
$serverlist1{$server} = sprintf "%s",$iplist;
print FILEWRITE "$server $iplist\n";
}
untie @servers;
local $now = time;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$o->STORE(++$n, "Start time = ".$hour.":".$min.":".$sec);
@files = <autotrack_*-$runday.out>;
foreach $arrayfiles(@files) #foreach autotrack file
{
$records = 1;
$line = 1;
tie @autotrack, 'Tie::File', $arrayfiles || die "Can't open: $!\n";
$o->STORE(++$n, "Processing autotrack file: ".$arrayfiles);
foreach $item (@autotrack) #foreach autotrack record
{
switch ($line)
{
case 1
{
$rec1 = $autotrack[$records];
@rec1 = split(/@/, $autotrack[$records]);
$user1 = "User name: ".$rec1[0];
$user = $rec1[0];
$terminal = $rec1[1];
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "user = ".$rec1[0]);
$o->STORE(++$n, "terminal = ".$rec1[1]);
}
++$line;
} #Close case 1
case 2
{
@datetime = split(/ /, $autotrack[$records]);
@rec21 = split(/\//, $datetime[0]);
$edate = sprintf "$rec21[0] $monthnames[$rec21[1]] $rec21[2]";
$edate1 = sprintf "Date: $rec21[0] $monthnames[$rec21[1]] $rec21[2]";
@rec22 = split(/:/, $datetime[1]);
$etime = sprintf "$rec22[0]:$rec22[1]";
$etime1 = sprintf "Time: $rec22[0]:$rec22[1]";
$edatetime = sprintf "$edate $etime";
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "date = ".$edate);
$o->STORE(++$n, "time = ".$etime);
$o->STORE(++$n, "date time = ".$edatetime);
}
++$line;
} #Close case 2
case 3
{
$event = $autotrack[$records];
@rec3 = split(/ /, $event);
$command = trimwhitespace($rec3[0]);
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "event = ".$event);
$o->STORE(++$n, "command = ".$command);
}
++$line;
} #Close case 3
case 4 { ++$line }
case 5
{
@rec5 = split(/:/, $autotrack[$records]);
$rec5[0] = trimwhitespace($rec5[0]);
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, $rec5[0]." = ".$rec5[1]);
}
++$line;
} #Close case 5
case 6
{
@rec6 = split(/:/, $autotrack[$records]);
$rec6[0] = trimwhitespace($rec6[0]);
$rec6[1] =~ s/^\s+//;
@rec61 = split(/ /, $rec6[1]);
foreach $array_element(@rec61)
{
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "rec61: ".$rec61[$index]);
}
$rec61[$index] =~ s/\"//g;
switch ($rec61[0])
{
case "sendevent"
{
switch ($rec61[2])
{
case "SET_GLOBAL"
{
$class1 = "Class: as-gvar";
$class = "as-gvar";
}
case "FORCE_STARTJOB"
{
$class1 = "Class: as-job";
$class = "as-job";
}
else
{
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "unmatched sendevent type");
}
}
}
}
else
{
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "unmatched command");
}
}
}
++$index;
} #Close foreach specific array_element
@rec62 = split(/\=/, $rec61[4]);
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, $rec6[0]." = ".$rec6[1]);
$o->STORE(++$n, "rec62 = ".$rec62[0].", ".$rec62[1]);
}
$index = 0;
++$line;
} #Close case 6
else
{
if ($autotrack[$records] eq
":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
{
++$auditrecords;
$search = sprintf
"$edatetime.*$class.*$command.*$terminal|$serverlist1[$terminal]";
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "Search value = ".$search);
$o->STORE(++$n, "Class = ".$class1.", resource = ".$rec62[0].", user
= ".$user1.", terminal = ".$terminal1.", date = ".$edate1.", time =
".$etime1);
}
$match = 0;
$array_files = "seosauditsuccess_".$terminal."_".$runday.".out";
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "connecting to file: ".$array_files);
}
tie @seosaudit, 'Tie::File', $array_files || die "Can't open: $!\n";
foreach $array_element(@seosaudit)
{
++$srecords;
if ($array_element =~ m/Total Records Displayed.*/)
{
next;
} #Close if
if($array_element =~ m/($search)/)
{
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "Class = ".$class1.", resource = ".$rec62[1].",
user = ".$user1.", terminal = Terminal: ".$terminal.", date =
".$edate1.", time = ".$etime1);
}
if ($match >= 6)
{
$found = 1;
$match = 0;
next;
}
} #Close if
if ($array_element =~ m/($class1)/)
{
++$match;
} #close if array_element
if ($array_element =~ m/Resource: ($rec62[0])\..*/)
{
++$match;
} #close if array_element
if ($array_element =~ m/($user1)/)
{
++$match;
} #close if array_element
if ($array_element =~
m/Terminal\:.*($terminal|$serverlist1[$terminal])/)
{
++$match;
} #close if array_element
if ($array_element =~ m/Program\:.*($command)/)
{
++$match;
} #close if array_element
if ($array_element =~ m/($edate1)/)
{
++$match;
} #close if array_element
if ($array_element =~ m/($etime1)/)
{
++$match;
} #close if array_element
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, "SeosAudit record = ".$array_element);
}
} #Close foreach
if ($found == 1)
{
$o->STORE(++$n, "Record found in the seosdb audit file: ".$array_files);
$found = 0;
$match = 0;
++$totalmatched;
}
elsif ($found == 0)
{
$o->STORE(++$n, "Record not found in the seosdb audit file!!!!
".$array_files);
$o->STORE(++$n, "Autotrack Data:\n\t".$class1.",\n\tResource:
".$rec62[0].",\n\t".$user1.",\n\t".$terminal1.",\n\tProgram:
".$command.",\n\t".$edate1.",\n\t".$etime1);
$found = 0;
$match = 0;
++$totalunmatched;
}
$line = 1;
untie @seosaudit;
} #Close if Last record of autotrack
elsif ($autotrack[$records] eq "")
{
$o->STORE(++$n, "\n\n");
} #Close else if
else
{
@recdef = split(/:/, $autotrack[$records]);
$recdef[0] = trimwhitespace($recdef[0]);
if ($debug == 1) #Create output if debug is on
{
$o->STORE(++$n, $recdef[0]." = ".$recdef[1]);
}
++$line;
} #Close else of last record if
} #Close of switch else for autotrack
} #Close of switch for autotrack
++$records;
# if ($records == 50)
# {
# $o->STORE(++$n, "Total unique Audit records read = ".$auditrecords);
# $o->STORE(++$n, "Total records matched = ".$totalmatched);
# $o->STORE(++$n, "Total records not matched = ".$totalunmatched);
# $now = time - $now;
# ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
# $o->STORE(++$n, "End time = ".$hour.":".$min."$:".$sec);
# $o->STORE(++$n, "It took ".int($now / 3600).":".int(($now % 3600) /
60).":".int($now % 60). "to process ".$arecords." Autotrack records and
".$srecords." Seoasdb records");
# exit;
# }
}
untie @seosaudit;
untie @autotrack;
$arecords = $arecords + $records;
}
$o->STORE(++$n, "Total unique Audit records read = ".$auditrecords);
$o->STORE(++$n, "Total records matched = ".$totalmatched);
$o->STORE(++$n, "Total records not matched = ".$totalunmatched);
$now = time - $now;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
$o->STORE(++$n, "End time = ".$hour.":".$min.":".$sec);
$o->STORE(++$n, "It took ".int($now / 3600).":".int(($now % 3600) /
60).":".int($now % 60)." to process ".$arecords." autotrack records and
".$srecords." Seosaudit records");
untie @logfile;
# Function to remove whitespace from the begining and the end of a string.
sub trimwhitespace($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+//;
return $string;
}
sub nslookup() {
my ($host, $word) = @_;
open(NSLOOKUP, "nslookup $host 2>&1 |") || die "nslookup error";
while (<NSLOOKUP>) {
if (/Name:.*$host\.eur\.nsroot\.net/) {
$found = 1;
}
last if (/$word/ & $found == 1);
if (/\*\*\*/) {
print "nslookup says: $_";
die "*** nslookup error";
}
}
close(NSLOOKUP);
s/$word:\s*//;
chomp;
$found = 0;
return $_;
}
Darren said:
In comp.lang.perl.misc Hendry Taylor said:
I wrote a perl script and tested it on windows and it works fine. I then
moved it onto a solaris machine and now it says that there is a syntax
error with the following line of code:
$user1 = "User name: ".$rec1[0];
the line of code just before that is:
@rec1 = split(/@/, $autotrack[$records]);
Is that code within a BLOCK? What is the exact error string that you're
getting?