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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.