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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.