Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uninitialized value message

Status
Not open for further replies.

carg1

MIS
Aug 19, 2003
20
0
0
US
In a script I'm working on, I'm using this block of code to convert a file's Date Modified as the filename for the output file:
Code:
#Ops stores the stat function ran on the previous input.
$Ops = (stat($DB))[9];

#Converts the date to a readable format
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($Ops);
$RMonth = $mon + 1; #Adds one to month to obtain the correct month
$SYear = ($year % 100); #Runs modulo arithmetic on the year to get the correct short year
@DateMod = ($RMonth, $mday, $SYear, $hour, $min);

#Stores the value of Ops, converted into a readable format, into the variable $Stuff
$Filename = sprintf("%02d%02d%02d%02d%02d", @DateMod);
It tells me I have an uninitialized value in
Code:
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($Ops);
when I run it with the -w option. I'm not exactly sure why it's telling me that. It's a part of a script that I'm integrating into one bigger script. More clearly, the script that contains that block of code used to be a standalone script. Now I'm integrating it into a script that runs that script and a few others through a menu. I have no problem getting any of the scripts to run, but that date issue is a major one since it names the output file based on that returned date. All the names it creates contain "1231691900" as the date.

In the menu, I want it to output the name of the open file:
Code:
INPUT2: print "\n\n\nWhat would you like to do next?\n\n";
print "The currently open file is: $Dir"."$DB\n\n";
print "1) Open another file\n";
print "2) Filter hits by blocked content\n";
print "3) Filter hits by passed content\n";
print "4) Count IP address instances\n";
print "5) Filter hits by IP address\n";
print "6) Exit the program\n";
print "\n\nYour choice: ";
$PickNumber = <STDIN>;
chomp($PickNumber);
It says the variables in the concatenation are uninitialized. I use the variables $Dir and $DB in an if statement that follows that, could that be why? I tried using defined in both cases, maybe I used it wrong, but that didn't work. I admittedly don't completely understand the concept of &quot;defined&quot;, I just saw that someone used that as a solution when I did a keyword search on the forum. Is there something I'm missing?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top