If you can tolerate the change of square brackets to curly braces, it's easy:
#!/usr/bin/perl use warnings; use strict; <DATA>; # Skip the header line my %table; while (<DATA>) { my ($chrom, $pos, $id, $ref, $alt, $qual) = split; $table{$chrom}{$pos} = { REF => $ref, ALT => $alt, QUAL => $qual, }; } print $table{chr1}{1092482}{REF}, "\n"; # Prints T, yay! __DATA__ #CHROM POS ID REF ALT QUAL chr1 1092344 . G T 79.54 chr1 1092367 . C T 148.50 chr1 1092400 . G C 90.54 chr1 1092424 . A G 93.14 chr1 1092461 . G A 105.30 chr1 1092470 . T G 103.06 chr1 1092482 . T C 104.33 chr1 1093235 . G A 16.08 chr1 1093245 . C T 244.75
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

In reply to Re: Load table with row/column names by choroba
in thread Load table with row/column names by cristianro87

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.