use warnings; use strict; my @names = qw( DONT MICH LEON RAPH SPLN SHRD CASY APRL FOOT BEBP RKST DUBY SAMH GRAW KNYN KP01 KP02 KP03 KP04 KP05 ); my %data; while (<DATA>) { next if /mcp/; chomp; my ($s, $n) = split; push @{ $data{$s} }, $n; } my $i = 1; for my $name (@names) { print "$i\n"; print "$_\n" for @{ $data{$name} }; $i++; } __DATA__ 20131201.06372602.mcp APRL 7.1963 BEBP 7.1979 CASY 7.3879 DONT 7.3196 DUBY 6.3729 FOOT 7.1496 GRAW 7.0046 KNYN 6.7313 LEON 7.4596 MICH 7.5579 RAPH 7.0563 RKST 6.6879 SAMH 6.9529 SHRD 6.2829 SPLN 6.1113 20131202.02185602.mcp APRL -2.1870 BEBP -2.3270 CASY -1.0153 DONT -0.1453 DUBY -1.9920 FOOT -2.1903 GRAW -1.5937 KNYN -2.0403 LEON -0.6237 MICH -1.5737 RAPH -1.3287 RKST -2.5337 SAMH -1.9653 SHRD -2.4087 SPLN -2.2053

Prints:

1 7.3196 -0.1453 2 7.5579 -1.5737 3 7.4596 -0.6237 4 7.0563 -1.3287 5 6.1113 -2.2053 6 6.2829 -2.4087 7 7.3879 -1.0153 8 7.1963 -2.1870 9 7.1496 -2.1903 10 7.1979 -2.3270 11 6.6879 -2.5337 12 6.3729 -1.9920 13 6.9529 -1.9653 14 7.0046 -1.5937 15 6.7313 -2.0403 16 17 18 19 20

In reply to Re: Using a Hash Variable in an If Statement by toolic
in thread Using a Hash Variable in an If Statement by Bama_Perl

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.