>>>>> "RZ" == Richard Zilavec <> writes:
>> I can split the vertical file on the "\n"
>> but will need a loop to add blank fields
>> to the end of the line if the options
>> do not total 6 so that the line always
>> has total of 12 fields even if there are
>> not a total of 6 options.
RZ> Try using map with the join statement.
RZ> for(0 .. 11) {
RZ> $array[$_] = $_;
and how does that help pad the array to 12 elements?
RZ> $array[$_] =~ s/^(.*)$/'$1'/;
since you just assigned each element, you could have just assigned
"'$_'" instead.
RZ> }
RZ> $string = join(',', map { $array[$_] }(0 .. 11));
huh??? why the map/array thing? that is just the same as @array!!
RZ> This produces which may be useful.
RZ> '0','1','2','3','4','5','6','7','8','9','10','11'
doesn't look too useful to me. the OP wanted more than that.
and where is the critical logic that loops over the items and options
and converts each set to a single line?
what the OP needs is a double nested loop or similar to track when he
sees an item number. push the following lines into an array until the
next item number (and keep track of that). then pad the array with empty
elements using push( @array, () x (12 - @array) ) to get 12
elements. then do some postprocessing with map and join. i leave the
coding as an exercise.
uri
--
Uri Guttman ------
--------
http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ----------------------------
http://jobs.perl.org