Hello,
I have written a script by using hashes. In my script I have used values independently. At the end, I have got output of a list of hash values...but now what I am looking for is getting the keys for the values (output). In simple, I am looking for the corrosponding keys for the values (output). The following is my script. Thank you very much.

#!/usr/local/bin/perl use warnings; # open a file and assign the filehandle FILE open(FILE, "2.txt") or die("can't open myfile.txt: $!\n"); while(<FILE>) { if($_ =~ /\s+(\S+)\s+(\S+)/) { $hash{$1} = $2; push(@index,$1); push (@a2, $2); } } close(FILE); # close the filehandle $i=0; while ($i<= ($#a2 - 1)) { $c1=$a2[$i]; $c2=$a2[$i+1]; $c3=$a2[$i+2]; $c4=$a2[$i+3]; $c5=$a2[$i+4]; $c6=$a2[$i+5]; $c7=$a2[$i+6]; $c8=$a2[$i+7]; $c9=$a2[$i+8]; $i++; if (($c1<$c2) && ($c2<$c3) && ($c3<$c4) && ($c4<$c5) && ($c5>$c6) && ( +$c6>$c7) && ($c7>$c8) && ($c8>$c9)) { $peak=$c5; print $peak, "\n"; } }

20050426 Janitored by Corion: Added formatting


In reply to Accessing keys through values by cybersmithuk

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.