develooper Front page | perl.beginners | Postings from May 2011

Use of uninitialized value warnings

Thread Next
From:
sono-io
Date:
May 31, 2011 09:33
Subject:
Use of uninitialized value warnings
Message ID:
C93F724A-0CEE-4EB1-9DBA-20E332D3A9B6@fannullone.us
Good Morning,

	I could use some help figuring out where a warning is coming from.

	My shopping cart script has the following sub:

695 sub get_ud {
696	my ($log, $pass) = $main::global->{login} ? ($main::global->{form}->{'userlogin'}, $main::global->{form}->{'userpass'}) : ();
697	$main::global->{form}->{'ud'} = "%%$main::global->{uid}%%$log%%$pass%%".time();
698	$main::global->{form}->{'ud'} = Encrypt($main::global->{form}->{'ud'}, $main::global->{config}->{'cookie'});
699 }

	These warnings are showing up in the log:

• Use of uninitialized value $log in concatenation (.) or string at line 697 (#1)
• Use of uninitialized value $log in concatenation (.) or string at line 697.
• Use of uninitialized value $pass in concatenation (.) or string at line 697 (#1)
• Use of uninitialized value $pass in concatenation (.) or string at line 697.

	Since both $log and $pass are defined in line 696, why is perl complaining about them in line 697?  I know they're only warnings, but is there a way to eliminate them?  I understand that I could use 'no warnings' in this sub, but I'd really like to understand what's causing them in the first place since I'm getting similar warnings throughout this script.

	Also, what does the "(#1)" signify?

	If I've left anything out, please let me know.

Thank you,
Marc

Perl 5.12.3
Mac OS 10.6.7


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About