Hi all,
What I need is to create simple config file which will map fields from csv files into anothers fields in another file. Simple, isn't it? So I created config file 'account.csv':

#User;LoginName;FullName;Description;Password;Profile;DefaultLibrary;S +tate $cfg[0] = "User;$line[2];$line[1];Default account for $line[1];$line[3 +];VIEWER;;"; #Acl;Name;Description;Users $cfg[1] = "Acl;$line[1];Default access list for $line[1];$line[2]#Supp +ort"; #Folder;Name;Description;Scope;Reports;Owner;Parent $cfg[2] = "Folder;$line[1];Default folder for $line[2];$line[1];;admin +istrator;/Customer_SLA";

Then I wrote script which open source csv file push each it line into @file. Then I need something like this:

foreach $line (@file) { @line = split(/;/,$line); require "account.cfg"; print $cfg[0]; foreach $cfg ( @cfg ) { push( @topol, $line[0].";".$cfg ); } }
So in @topol should be for each line of source csv file, three lines for each line of config. But, sure, this doesn't work because I can't use perlfunc:require by this way. (only for first pass are variables filled from @line array) This is only "non working example" :-))) of what I need. There is only one condition: config must simple, even for non Perl users. I can use regex to replace some marks by values but I am sure, that easier way must exist.

I am sure that there is way, but I am so stupid to find it. :-) And what about you? Thanks

Li Tin O've Weedle
mad Tsort's philosopher


In reply to easy config file by LiTinOveWeedle

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.