Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Text Files
by sauoq (Abbot) on Oct 08, 2002 at 18:14 UTC

    This question is very poorly stated. I've read it three times and still have no idea what you want. You are using the terms "element" and "header" ambiguously at best.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Text Files
by cciulla (Friar) on Oct 08, 2002 at 23:10 UTC
    I'm used to interpreting gibberish -- maybe I should add that to my skillset.

    Anywho, I'm positive that there's a better way of doing this, but A. Monk's panic was almost palpable. At least it runs with -w with minimal fuss.
    open INFILE, "flatFile.csv" || die("Can't read flatFile.csv"); open OUTFILE, ">flatFile.out" || die("Can't open flatFile.out"); $MAX_PARAMS = 11; $THIS_PAGE = "http://mypage.com/new/test.pl?opt_1=FIELD1&opt_2=FIELD2& +opt_3=FIELD3&opt_4=FIELD4&opt_5=FIELD5&opt_6=FIELD6&opt_7=FIELD7&opt_ +8=FIELD8&opt_9=FIELD9&opt_10=FIELD10&ins_company=FIELD0&t=s"; $THIS_DELIMTER = ","; while (<INFILE>) { @theseFields = split/$THIS_DELIMTER/; $paramLength = @theseFields; $paramLength == $MAX_PARAMS || warn("expected $MAX_PARAMS parameters, $paramLength paramet +ers found:"); $finalPage = $THIS_PAGE; for ($i = 0; $i < $MAX_PARAMS; $i++) { $finalPage =~ s/FIELD$i/$theseFields[$i]/gi; } print OUTFILE "$finalPage\n"; } close OUTFILE; close INFILE;


    I smell your fear! Thank you, Glans Jupiter!
      Thank you for your help, I am sorry for my obscure way to ask question. Thanks again!!!!!!!!!
Re: Text Files
by kabel (Chaplain) on Oct 08, 2002 at 18:55 UTC
    what sauoq stated is true for me, too.

    apart from that, i think there is a logical flaw inside your file:
    first is a name, then a description, then ten fields with unknown content. you use the ',' as delimiter. but the third line's description contains ',' - the delimiter. that must not be! be sure to check the file against this.
Re: Text Files
by nutshell (Beadle) on Oct 08, 2002 at 19:53 UTC
    Yeah, I have no clue what you're after either...

    --nutshell