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! |