All code below is untested
Update: suggestion about splitting is valid only if the result from database is "|"-separated, as cleverly pointed out here...
You had to say it immediately: my @strings = split /\|/, $status;
Note that, by default, putting @sorted_strings in double quotes will give you space-separated items. You can change the separator using the perlvar $":{
local $" = "|";
print "<br><font color=red>@sorted_strings</font><br>";
}
I put the curly brackets in order to restrict the modification of the $" variable, making this modification "visible" to the print statement only.
Anyway, I'd probably use a more flexible, metadata-based approach: my %subst (
P => 'Posted',
F => 'Posted',
C => 'Posted',
D => 'Posted',
I => 'Posted',
A => 'Accepted',
N => 'New',
R => 'Rejected',
S => 'Save',
X => 'Canceled',
);
my @sorted_strings = sort map { $subst{$_} } split /\|/, $status;
# The above line can be roughly expanded to the three lines below:
#
# my @status_letters = split /\|/, $status;
# my @strings;
# foreach (@status_letters) {
# push @strings, $subst{$_}
# }
# my @sorted_strings = sort @strings;
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Don't fool yourself.
|