G'day AhmedABdo,
This looks like an "XY Problem" to me. In addition, it looks like you've typed, rather than pasted, your code, which has resulted in typos: My should be my; "Hello" is either missing from @array, extraneous to %hash, or an explanation of how it relates to the rest of your post has been omitted. I see others have already pointed out further issues: I won't repeat those comments here but I do agree with them.
Perhaps what you're looking for can be achieved with the enum module. Here's a script with a couple of examples of usage:
#!/usr/bin/env perl -l use strict; use warnings; use enum qw{world=1 today is nice}; print '"world today" from enum'; print for world, today; print '"today is nice" from array'; my @indices = (today, is, nice); print for @indices;
Output:
"world today" from enum 1 2 "today is nice" from array 2 3 4
— Ken
In reply to Re: Search hash keys using values from array
by kcott
in thread Search hash keys using values from array
by AhmedABdo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |