M
Mike Solomon
I have written the following code that does what I require but I am
sure it could be done better
How can I improve this
my @required = (
{company => "Company is required"},
{address1 => "Address1 is required"},
{postcode => "Postcode is required"},
{phone => "Phone is required"},
);
my (@key, @value);
for (@required) {
for (keys %{$_}) { push @key, qq {'$_'};}
for (values %{$_}) { push @value, qq {'$_'};}
}
my $key = join "," , @key;
my $value = join "," , @value;
return $key , $value;
sure it could be done better
How can I improve this
my @required = (
{company => "Company is required"},
{address1 => "Address1 is required"},
{postcode => "Postcode is required"},
{phone => "Phone is required"},
);
my (@key, @value);
for (@required) {
for (keys %{$_}) { push @key, qq {'$_'};}
for (values %{$_}) { push @value, qq {'$_'};}
}
my $key = join "," , @key;
my $value = join "," , @value;
return $key , $value;