This is a small program used to list the alert_logs of various databases listed in a text file (oratab). When I run the program the while loop picks up all the database names from the oratab but when the %dbLogLst hash is called in a subsequent foreach loop it randomly encounters variable initialization errors. The errors are random but consistent in that they databases giving errors are always the same. I'm hoping this is something obvious... I'm new to Perl so any help is greatly appreciated.
----------------------------------------------------------- #!/usr/bin/perl # use warnings; use strict; # my ($db,$line,$home,$boot,$bkup,$dbName,@dbList,%dbHomeLst,%db +BkupLst,%dbBootLst,%dbLogLst); my $oratab = $ENV{'ORATAB'}; # open OT, "$ENV{'ORATAB'}" + or die "Oratab not accessible ($!)"; while (defined ($line = <OT>)) { next if $line =~ /^#/; next if $line =~ /^\s*$/; chomp $line; ($dbName, $home, $boot, $bkup) = split ":", $line; push (@dbList,$dbName); print "DBNAME = $dbName\n"; $dbHomeLst{$dbName} = $home; $dbBkupLst{$dbName} = $bkup; $dbBootLst{$dbName} = $boot; $dbLogLst{$dbName} = < $ENV{'DIAG'}/$dbName/log/alert_ +$dbName.log >; } close OT; # # My Tests # foreach $db (@dbList) { print "Name = $db\n"; print "Home = $dbHomeLst{$db}\n"; print "Bkup = $dbBkupLst{$db}\n"; print "Boot = $dbBootLst{$db}\n"; print "DbLog = $dbLogLst{$db}\n"; } -------------------------------------------------------------
The output:
DBNAME = bea DBNAME = busopp DBNAME = cdms DBNAME = cip Name = bea Home = /orasys00/app/oracle/product/9.2.0 Bkup = Y Boot = Y DbLog = /orasys00/app/dpc/bea/log/alert_bea.log Name = busopp Home = /orasys00/app/oracle/product/9.2.0 Bkup = Y Boot = Y Use of uninitialized value in concatenation (.) or string at listDbs.p +l line 31. DbLog = Name = cdms Home = /orasys00/app/oracle/product/9.2.0 Bkup = Y Boot = Y DbLog = /orasys00/app/dpc/cdms/log/alert_cdms.log Name = cip Home = /orasys00/app/oracle/product/9.2.0 Bkup = Y Boot = Y Use of uninitialized value in concatenation (.) or string at listDbs.p +l line 31. DbLog =
Here is the sample OraTab file:
bea:/orasys00/app/oracle/product/9.2.0:Y:Y busopp:/orasys00/app/oracle/product/9.2.0:Y:Y cdms:/orasys00/app/oracle/product/9.2.0:Y:Y cip:/orasys00/app/oracle/product/9.2.0:Y:Y
In reply to Random Unitialized Value Errors by dbadude
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |