The code seems overly complex to me.
There are some steps:
a) parse the input lines and assign values to some variables.
b) Use those variables to create the data structure.

The below could be a way to parse the data.
A HoHoH is a pretty complex data structure. What are you trying to do? There might be some better alternatives, but I don't know enough to comment on that. Can you explain more about your objective?

#!usr/bin/perl -w use strict; my %site_info=(); while (<DATA>) { next if /^\s*MULTI/; #skip MULTI lines next if /^\s*$/; #skip blank lines # default split is /\s+/ which includes # all of the whitespace charaters [ \n\r\f\t] # From the data shown (no spaces within the # tokens), why not just split on simple whitespace? my ($chrStr, $strand, $value) = (split)[0,1,3]; # ditch the dash # use simple regex to get the "chr number" my ($chrNum) = $chrStr =~ /(\d+)/; #just get the digits.. print "$chrNum $strand $value\n"; } =prints 16 28797601 0.777877 32 887755 0.11 =cut __DATA__ chr16 28797601 - 0.777877 MULTI some stuff chr32 887755 - 0.11

In reply to Re: Can't use string ("16") as a HASH ref while "strict refs" in use by Marshall
in thread Can't use string ("16") as a HASH ref while "strict refs" in use by thudzj

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.