Hi Monks,

I have some doubts related to file operations and hash of arrays which are as follows:

1. I would like to know that how will I do the translation/ substitution operation on the data stored in Hash of Array data structures.

2. If I have a file 4 columns where the first column act as the id (which can be repeated) and the other three columns are the integer values.

DATA: id col1 col2 col3 12 100 12 196 12 120 15 190 13 90 190 200 13 70 20 20 13 101 340 25 14 100 123 19 15 80 389 39

I have read the entire data in a file into Hash of Array. I would like to know how can I do the sum of the rows without taking the the values of the same id present in other columns of the file. My output should look like :

Output: id Sum 12 308 12 325 13 480 13 110 13 466 14 242 15 508

3. Is their any faster option to delete any column of the file without reading it line by line and then deleting the column using splice function or shift (for deleting the first column) etc.


In reply to Hash of Arrays and File Operations by snape

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.