Hi,
Is it possible in perl to have a hash defined with variables as theirs key values, like:
%account = ('username' => 'boy', 'password' => $password);
Thanks
Hi,
Is it possible in perl to have a hash defined with variables as theirs key values, like:
%account = ('username' => 'boy', 'password' => $password);
Thanks
Yes.
my $usernamekey='UNIX';
my $passwordvalue='XXXXXX';
my %acct=( $usernamekey => 'boy',
'password' => $passwordvalue );
my @k=keys %acct;
my @v=values %acct;
print "Keys : @k\n";
print "values : @v\n";
produces
Keys : password UNIX
values : XXXXXX boy