[TriLUG] perl: how to initialise a variable that I want to be NULL

Joseph Mack NA3T jmack at wm7d.net
Sun Aug 16 19:51:40 EDT 2009


Scott's code is working for my database queries now. Thanks 
that's a big relief.

I assemble my query string iteratively

my $database_command = magic strings to talk to database
my @words = parseline($user_input);	#parsed input from user 
my $query_string;		#declare query string variable

while (@words){
 	$query_string = $database_command . pop(@words) . $query_string;
}

Then I send $query string to the database.

However on the first pass through the loop I get the warning 
"$query_string uninitialised". I can stop this message by 
initialising the variable to ' ' when I declare it (this 
extra blank doesn't affect the query) but it seems a kludge. 
Initialising it to '' apparently is not initialising it, as 
I still get the message. Is there a better way to not get 
the message?

Thanks Joe

-- 
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!



More information about the TriLUG mailing list