$template->param($textField, $self->param($textField) ||
$userData->{$textField} || '');
$finalData{$textField} = $template->param($textField);
####
my %fieldHandler = (
textField => sub
{
my $field = shift;
$template->param($field, $self->param($field) || $userData->{$field} || '');
$finalData->{$field} = $template->param($field);
},
checkBox => sub
{
my $field = shift;
if ($self->param($field) eq '1' || $userData->{$field} eq '1')
{
$template->param($field,'checked');
$finalData{$field} = 1;
}
},
fixField => sub
{
my $field = shift;
if ($which eq 'INTERNAL')
{
$template->param($field, $self->param($field) || $userData->{$field} || '')
}
},
);
my %fieldMap = (
fullname => 'textField',
username => 'textField',
authname => 'textField',
email => 'textField',
chk1 => 'checkBox',
chk2 => 'checkBox',
chk3 => 'checkBox',
emp_id => 'fixField',
emp_name => 'fixField',
emp_cat => 'fixField',
);
foreach my $fieldName (keys %fieldMap)
{
my $handler = $fieldMap{$fieldName};
$fieldHandler{$handler}->($field);
}
####
my @fieldNames = qw(fullname username authname email chk1 chk2 chk3 emp_id emp_name emp_cat);
foreach my $fieldName (@fieldNames)
...