![]() |
|
P is for Practical | |
PerlMonks |
Re: using hash to compare with string and print the stringby thanos1983 (Parson) |
on May 16, 2019 at 08:59 UTC ( #11100053=note: print w/replies, xml ) | Need Help?? |
Hello Newbie95, Just a minor note here because you said you are doing your first steps on hashes. I noticed that you have an array of keys and a hash below. If the hash is not manually defined you can use hash slicing and assign the keys and values in one step to avoid typing everything manually. For example see below:
Then simply as fellow Monks demonstrate to you, iterate over the keys and if the key exists print.
Here is the documentation regarding perldata/Slices. In case you want to read a bit more on how to play with them :). BR / Thanos
Seeking for Perl wisdom...on the process of learning...not there...yet!
In Section
Seekers of Perl Wisdom
|
|