S
s. keeling
I've built a HoA as so:
my %prompt = (
FIRST_NAME => [ qq(NULL), qq(NULL), qq(\tFirst name -> ),
qq(You MUST supply a first name.\n) ],
LAST_NAME => [ qq(NULL), qq(NULL), qq(\tLast name -> ),
qq(You MUST supply a last name.\n) ],
and so on. I'd like to write to and access $prompt->{$key}[2] when
prompting a user for the name, and I'd like to stuff the reply in
$prompt{$key}[1], then compare that with $prompt->{$key}[0], which
I'll try to supply via a call to mysql.
# FIRST_NAME
#
my $key = qq(FIRST_NAME);
print STDOUT qq($prompt->{$key}[2]);
$prompt->{$key}[1]=<STDIN>;
chomp($prompt->{$key}[1]);
if ( ! $prompt->{$key}[1] ) {
die $prompt->{$key}[3];
}
What I get is:
Use of uninitialized value in string at ./mupdate.pl line 154 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.
Use of uninitialized value in die at ./mupdate.pl line 158, <STDIN> line 1 (#1)
Died at ./mupdate.pl line 158, <STDIN> line 1 (#2)
(F) You passed die() an empty string (the equivalent of die "") or
you called it with no args and both $@ and $_ were empty.
Uncaught exception from user code:
Died at ./mupdate.pl line 158, <STDIN> line 1.
at ./mupdate.pl line 158
I think I'm using the same sort of thing, using the same syntax as
Perl Cookbook and Camel say it's to be done. It sort of works when I
use $prompt{$key}[N] instead. What am I confusing?
my %prompt = (
FIRST_NAME => [ qq(NULL), qq(NULL), qq(\tFirst name -> ),
qq(You MUST supply a first name.\n) ],
LAST_NAME => [ qq(NULL), qq(NULL), qq(\tLast name -> ),
qq(You MUST supply a last name.\n) ],
and so on. I'd like to write to and access $prompt->{$key}[2] when
prompting a user for the name, and I'd like to stuff the reply in
$prompt{$key}[1], then compare that with $prompt->{$key}[0], which
I'll try to supply via a call to mysql.
# FIRST_NAME
#
my $key = qq(FIRST_NAME);
print STDOUT qq($prompt->{$key}[2]);
$prompt->{$key}[1]=<STDIN>;
chomp($prompt->{$key}[1]);
if ( ! $prompt->{$key}[1] ) {
die $prompt->{$key}[3];
}
What I get is:
Use of uninitialized value in string at ./mupdate.pl line 154 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.
Use of uninitialized value in die at ./mupdate.pl line 158, <STDIN> line 1 (#1)
Died at ./mupdate.pl line 158, <STDIN> line 1 (#2)
(F) You passed die() an empty string (the equivalent of die "") or
you called it with no args and both $@ and $_ were empty.
Uncaught exception from user code:
Died at ./mupdate.pl line 158, <STDIN> line 1.
at ./mupdate.pl line 158
I think I'm using the same sort of thing, using the same syntax as
Perl Cookbook and Camel say it's to be done. It sort of works when I
use $prompt{$key}[N] instead. What am I confusing?