in reply to Scalars as hash keys?
In line 8 (the hash declaration, which continues through line 15), you have the curious construct Fastolfe mentioned in passing. The scalar variables in double quotes will be interpolated -- unfortunately, as the variables have never been defined, they throw the undefined value warning on line 8.
I think this may be more to your liking:
Does that make more sense? The key in the %prompts hash is the prompt. The value is the slot in the tied hash to which the data entered at that prompt corresponds.my %prompts = ( 'Enter new password' => 'newpass', 'Enter old password' => 'oldpass' ); my %tied_hash; # tie here for my $prompt (keys %prompts) { print $prompt; chomp(my $input = <STDIN>); $tied_hash{$prompts{$prompt}} = $input; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Scalars as hash keys?
by Fastolfe (Vicar) on Oct 27, 2000 at 00:26 UTC | |
by ybiC (Prior) on Oct 27, 2000 at 00:50 UTC | |
|
RE: (2) Scalars as hash keys? (getting closer 8^)
by ybiC (Prior) on Oct 27, 2000 at 00:30 UTC |