CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Use of uninitialized value in string eq?

 



AndrewF
Novice

Jul 29, 2013, 3:56 PM

Post #1 of 4 (480 views)
Use of uninitialized value in string eq? Can't Post

open (FILE1, "EQ_CS_01.txt");
my @file1_values=();
my $list=();
while (<FILE1>)
{
next if $. == 1; #Skips header line, and goes to actual content
chomp; #removes newline
(@file1_values) = split (/\|/); #declares arrays, splits file by pipe delimiters
foreach $list (@list_CEC)
{
if ($list eq $file1_values[2])
{
push (@ticker, $file1_values[1]);
push (@CEC, $file1_values[2]);
}
}
}
close (FILE1);
print "Done with file one, beginning file two\n";
THis is just one section of a larger script, but despite getting these error messages it will still run the whole program.
Can anyone tell my Im getting a "use of uninitialized value in string eq" errot message? I will provide any insight needed, and thank you in advance!


FishMonger
Veteran / Moderator

Jul 29, 2013, 4:52 PM

Post #2 of 4 (475 views)
Re: [AndrewF] Use of uninitialized value in string eq? [In reply to] Can't Post

That's not an error message, it's a warning.

Which line did the message refer to?


Laurent_R
Veteran / Moderator

Jul 30, 2013, 3:54 AM

Post #3 of 4 (465 views)
Re: [AndrewF] Use of uninitialized value in string eq? [In reply to] Can't Post

You get the warning most probably on this line:


Code
if ($list eq $file1_values[2])


because one of the two variables that you compare is undefined. Since $list is most probably defined (part of the foreach loop), that means that $file1_values[2] is probably undefined, meaning that the split of the input line yielded less that 3 fields. The warning message probably tells you on which line of the file you have the problem. Check that line. It could just be an empty line at the end of the file.


AndrewF
Novice

Jul 30, 2013, 1:44 PM

Post #4 of 4 (456 views)
Re: [Laurent_R] Use of uninitialized value in string eq? [In reply to] Can't Post

Ahh yes, thanks!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives