pearllearner315 has asked for the wisdom of the Perl Monks concerning the following question:
Any help would be great. Thanks so much!#!/usr/bin/perl use warnings; use strict; # defines country => language hash my %langs = ( England => 'English', France => 'French', Spain => 'Spanish', China => 'Chinese', Germany => 'German'); my $countryid = 'England'; my $langsref = \%langs; # get language of England my $englishlang = %{ $langsref }{$countryid}; # <---- this doesn't wo +rk. I wanna do the assignment all in this one line but can't figure o +ut assigning while dereferencing. print $englishlang;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: assigning value of a key in a hash to a variable while dereferencing
by jwkrahn (Abbot) on Sep 17, 2018 at 05:20 UTC | |
|
Re: assigning value of a key in a hash to a variable while dereferencing
by Athanasius (Archbishop) on Sep 17, 2018 at 06:13 UTC | |
|
Re: assigning value of a key in a hash to a variable while dereferencing
by AnomalousMonk (Archbishop) on Sep 17, 2018 at 16:01 UTC | |
|
Re: assigning value of a key in a hash to a variable while dereferencing
by Anonymous Monk on Sep 17, 2018 at 22:28 UTC | |
|
Re: assigning value of a key in a hash to a variable while dereferencing
by BillKSmith (Monsignor) on Sep 18, 2018 at 15:21 UTC |