Loading ...
Sorry, an error occurred while loading the content.

27474Re: [PBML] Parsing generic file

Expand Messages
  • Shlomi Fish
    Jul 25, 2013
    • 0 Attachment
      Hi Rajagopal,

      On Wed, 24 Jul 2013 23:33:11 -0000
      "Rajagopal" <raaajah@...> wrote:

      > Guys, I need help with this.
      >
      > I need to write a perl program that should output a file. Parameters are:
      >
      > SomePerl.pl infile outfile 8 5 10.
      >
      > infile can be any standard file with a header record with a delimiter.
      > Columns (numbers, names and position) can change from file to file.
      >
      > outfile is the output I want with the following:
      >
      > asset_id~asset_tag~asset_cl~col1|col2|col3|....
      > where asset_id, asset_tag and asset_cl is mapped to columns 8, 5 and 10.
      > Column header in the file may not be exactly named as asset_id, asset_tag or
      > asset_cl. Output file row should look like:
      >
      > col8~col5~col10~col1|col2|col3|col4|col5|col6|col7|col8|col9|col10
      >
      > I am new to perl and how would I achieve this?
      >

      I find it hard to understand exactly what you want to do, but you should look
      into the following resources for insights:

      1. File Input/Output in Perl -
      http://perl-begin.org/topics/files-and-directories/ .

      2. Regular expressions for matching text -
      http://perl-begin.org/topics/regular-expressions/ .

      3. Text::CSV and friends for robust input/output to Comma-Separated-Value (CSV)
      files:

      http://perl-begin.org/uses/text-parsing/#with-what-to-parse

      4. Make sure you avoid using commonly-used bad elements in Perl:

      http://perl-begin.org/tutorials/bad-elements/

      ================

      *Note*: http://perl-begin.org/ is a site I originated and maintain, but I
      believe the links I've given there are of relevance here.

      Furthermore, in the future, you may wish to post your question to
      beginners@... , where there are more people who can help you:

      http://learn.perl.org/faq/beginners.html

      Regards,

      Shlomi Fish


      --
      -----------------------------------------------------------------
      Shlomi Fish http://www.shlomifish.org/
      What Makes Software Apps High Quality - http://shlom.in/sw-quality

      He says “One and one and one is three”.
      Got to be good‐looking ’cause he’s so hard to see.
      — The Beatles, “Come Together”

      Please reply to list if it's a mailing list post - http://shlom.in/reply .
    • Show all 2 messages in this topic