User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 456,496 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,742 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 1170 | Replies: 2
Reply
Join Date: Sep 2007
Location: Near Arctic Circle
Posts: 5
Reputation: DaveHammer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
DaveHammer DaveHammer is offline Offline
Newbie Poster

Question keep getting "unitialized value in array element"

  #1  
Sep 19th, 2007
I keep getting the following errors everytime I call my "get_prevday" subroutine which is at the bottom. I have initialized all the variables in the program that I can think of. Please help!!:

"Use of uninitialized value in array element at
Thickness_vs5.cgi line 542. <FILE> line 71. "

"Use of uninitialized value in array element at
Thickness_vs5.cgi line 543. <FILE> line 71. "


.
.
my @date, $m, $md, $y, $epochtime;
$date[$x]= get_prevday($date[$x]);
.
.
.
###################Subroutines ###################
LINE 542 ->sub get_prevday { $date[$x] = shift || return(0);
LINE 543 ->($m,$md,$y) = $date[$x] =~ m|(\d+)/(\d+)/(\d+)|;
$epochtime = timelocal_nocheck(0, 0, 0, $md-1, $m-1, $y);
return strftime("%m/%d/20%y",0,0,0,(localtime($epochtime))[3,4,5]);}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Location: North Bay Ontario
Posts: 176
Reputation: trudge is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 20
trudge trudge is offline Offline
Junior Poster

Re: keep getting "unitialized value in array element"

  #2  
Sep 19th, 2007
Originally Posted by DaveHammer View Post
I keep getting the following errors everytime I call my "get_prevday" subroutine which is at the bottom. I have initialized all the variables in the program that I can think of. Please help!!:

"Use of uninitialized value in array element at
Thickness_vs5.cgi line 542. <FILE> line 71. "

"Use of uninitialized value in array element at
Thickness_vs5.cgi line 543. <FILE> line 71. "


.
.
my @date, $m, $md, $y, $epochtime;
$date[$x]= get_prevday($date[$x]);
.
.
.
###################Subroutines ###################
LINE 542 ->sub get_prevday { $date[$x] = shift || return(0);
LINE 543 ->($m,$md,$y) = $date[$x] =~ m|(\d+)/(\d+)/(\d+)|;
$epochtime = timelocal_nocheck(0, 0, 0, $md-1, $m-1, $y);
return strftime("%m/%d/20%y",0,0,0,(localtime($epochtime))[3,4,5]);}


It looks to me like the culprit might be line 71 in whatever file / data you are reading. Have you checked that source for maybe a missing data field?
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
Reply With Quote  
Join Date: Mar 2006
Posts: 642
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 36
KevinADC's Avatar
KevinADC KevinADC is online now Online
Practically a Master Poster

Re: keep getting "unitialized value in array element"

  #3  
Sep 20th, 2007
You don't want to do this:

$md-1

I explained why in your other thread.


Where is $x getting defined?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Perl Forum

All times are GMT -4. The time now is 3:26 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC