M
mike solomon
I have written the following code to create a variable in the format of
'code' , 'value' , 'description'
I know i could have just said:
my $arrField = "'code' , 'value' , 'description'";
but i think it is neater to put the code pairs into a hash
What I want to know if if there is a better way of doing this, as the
way I have come up with is a bit messy
my %required = (
code => "Code is required",
value => "Value is required",
description => "Description is required",
);
my @arrField ;
my @arrMess;
for my $key (keys %required) {
push @arrMess , qq {'$required{$key}'};
push @arrField, qq {'$key'};
}
my $arrMess = join "," , @arrMess;
my $arrField = join "," , @arrField;
Regards
Mike Solomon
'code' , 'value' , 'description'
I know i could have just said:
my $arrField = "'code' , 'value' , 'description'";
but i think it is neater to put the code pairs into a hash
What I want to know if if there is a better way of doing this, as the
way I have come up with is a bit messy
my %required = (
code => "Code is required",
value => "Value is required",
description => "Description is required",
);
my @arrField ;
my @arrMess;
for my $key (keys %required) {
push @arrMess , qq {'$required{$key}'};
push @arrField, qq {'$key'};
}
my $arrMess = join "," , @arrMess;
my $arrField = join "," , @arrField;
Regards
Mike Solomon