One more quick question ! If my NASTRAN output file was something like this:

1 2 3 4 5

1 20 30 40 50

1 9 3 3 6

4 6 7 9 0

4 4 8 90 8

4 5 2 7 20

9 5 2 7 20

9 20 30 40 50

9 4 8 90 8

The start of each line (The first number) represent an element ID. Would it possible to create a hashes of nested arrays where each element ID is the key for the created nested array. I know it does not make sense, but I need a seperate nested array for each element ID (start of each line) so that I can sort it later on based on a chosen column and print it. I have to get the all the lines that starts with first element put them in a nested array in a way which is described in the first message and later create a hash where the key is the element ID and points to a nested array which has all the information about that particular element. Basically: Element ID (key for the hash) = 1 points to a nested array of

1 '1 2 3 4 5'

1 '1 20 30 40 50'

1 '1 9 3 3 6'

Element ID = (key for the hash) = 4 points to a nested array

4 '4 6 7 9 0'

4 '4 4 8 90 8'

4 '4 5 2 7 20'

Element ID = (key for the hash) = 9 points to a nested array

9 '9 5 2 7 20'

9 '9 20 30 40 50'

9 '9 4 8 90 8'

I am not sure if this is the best way of doing it but I can not think of any other way. Any Help will be appreciated. Thanks a lot.


In reply to Re: Re: How to read each line of a file into a nested array by opolat
in thread How to read each line of a file into a nested array by opolat

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.