Hi Fshah,
I think some clarification about PerlMonks is in order.
This is a site where you can ask questions with the intent of learning about Perl. I am completely happy to help you learn at no charge. I am happy if you are learning. I am not happy if you are not learning.

Right now it appears that you are expecting me to write your code for you - without demonstrating much effort on your part.

I do have clients that pay me for solving their problems. Quite frankly these folks will get much higher priority than you. However I and others here are willing to help you learn. BUT, that means that you need to show some coding effort.

Your points 4,5,6 and 7 tell me that you didn't run much less understand the code which I modified for you.

1) Transposing a table, converting rows to columns is not that difficult if you think logically about it. I want to see a serious attempt by you. Use the 2-d table that my code generates.

2) Setting the current field to what was before in the case that it is "blank" (whether row-wise or column-wise) is also something that you should be able to make an attempt at.

The construction of a state machine to parse your various tables was beyond either of these tasks and I felt that it was necessary to get you "unstuck".

Solving this problem will help you. Write code that generates @transposed using @array as input. I know its hard, but give it a go...

#!/usr/bin/perl use strict; use warnings; my @array = ( ['a', '1', 'L'], ['b', '2', 'M'], ['c', '3', 'N'], ['d', '4', 'O'],); my @transposed = ( ['a', 'b', 'c', 'd'], ['1', '2', '3', '4'], ['L', 'M', 'N', 'O'],); foreach my $row_ref (@array) { print "@$row_ref\n"; } # Prints: #a 1 L #b 2 M #c 3 N #d 4 O foreach my $row_ref (@transposed) { print "@$row_ref\n"; } # Prints: #a b c d #1 2 3 4 #L M N O

In reply to Re^5: Parsing .txt into arrays by Marshall
in thread Parsing .txt into arrays by Fshah

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.