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!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.