$choices = ",1,2,3,4,5,6,"; #### $data{$user_type}{$user_company}{$user_lname}{'attribute'} #### $data{$user_type}{$user_company$}{$user_lname}{'choice_list'} = [ @split_list ]; #### $choices = ",1,2,3,4,5,6,"; print "Perl script output -
choices list before regex = $choices\n"; #string cleanup $choices =~ s/^,//; $choices =~ s/,$//; print "
choices list after regex = $choices\n"; @split_list = split(/,+/, $choices); # debugging output to check split for $i (0 .. $#pub_list) { print "
choice $i = $pub_list[$i]\n"; } $data{$user_type}{$user_company$}{$user_lname}{'choice_list'} = [ @split_list ]; $vars = { data => \%data, }; $template->process($template_file, $vars); ##
## Template output -
Choices are:
[% FOREACH type IN data.keys.sort %] [% FOREACH company IN data.$type.keys.sort %] [% FOREACH name IN data.$type.$company.keys.sort %] [% FOREACH choice IN data.$type.$company.$name.choice_list %] [% data.$type.$company.$name.choice_list.$choice %]
[% END %] [% END %] [% END %] [% END %] ##
## Perl script output -
choices list before regex = ,1,2,3,4,5,6,
choices list after regex = 1,2,3,4,5,6
choice 0 = 1
choice 1 = 2
choice 2 = 3
choice 3 = 4
choice 4 = 5
choice 5 = 6 Template output -
Choices are:
2
3
4
5
6