Ok, these are my recommendations. I'd recommend not using a pipe delimited file at all, but look closely at the CPAN module Config::Simple. Why?

Parsing a pipe delimited file usually gets done something like this:
my $data = `grep -i $account_name /config/data.file`; my @parms = split /|/, $data;
Which leads to writing code like this:

unless ( -d $parms[3] ) { # # do some ftp stuff here. # }
And this kind of code, which relies on the context of the fields of the pipe delimited file, is hard to read and hard to maintain, and even harder to extend.

The advantage in Config::Simple is that you have context, the keys and the values. The code no longer becomes dependent on the order of data in your data file. You won't create a massive mess if you insert another value in the middle of an entry in a Config::Simple file, whereas the maintenance issues you'll create with careless use of field position in a pipe delimited file will be huge.

If you have to go the pipe delimited method, I'd either have a separate file that map the configuration of the pipe file, and then I'd insert your pipe values into a hash (by mapping hash keys to positions of your parameters) or have a header at the top of the pipe delimited file that does the same; one that is read by the program and used to set the names of values.

You /do not/ want to have to find your FTP program has become a SFTP and oh, by the way, they want you to transmit on port 2222 rather than 22 after you've hard coded your pipe delimited field positions into your Perl.


In reply to Re: Perl record types by dwm042
in thread Perl record types by naveed010

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.