Hi beginr,

What's your definition of "column"?

Is it always a fixed number of characters, starting at a fixed character position in the file?  That will be quite easy in Perl.

Or does it depend on how you "delimit" your columns?  For example, if your data is always separated by whitespace (eg. spaces or tabs), or some other well-defined set of characters, then that's quite easy too.

The problem is, we can't solve your problem until we know what you need to do.  Even then, we need to know you've tried for yourself, and where you're getting stuck.  It wouldn't do us much good to say "After you've read the file into memory, do the following", and then find out that you're stuck on how to open and read a file from disk.  Nor would it productive to say "Just use regexes to extract the data you want" if it's regular expressions that you're unclear about.

And most importantly, if you have any code that you've written, by all means show us that, as an example program is almost always the best starting point.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Re: Reading selected columns from text file by liverpole
in thread Reading selected columns from text file by beginr

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.