$order = "ABCDE";
%valByKey
{ A => \A_value }
{ B => \B_value }
{ C => \C_value }
{ D => \D_value }
{ E => \E_value }
####
sub getByKey {
my $key = shift;
## to top.
$order =~ s[(^.*)($key)][$2$1];
## Needs quotemetaing and adjusting for 3-char keys
## may also require C
## to prevent that when the item being moved is at
## the beginning or the end of the string.
## to bottom ## $order =~ s[($key)(.*$)][$2$1];
## up one ## $order =~ s[(.?)($key)][$2$1];
## down one ## $order =~ s[($key)(.?)][$2$1];
## up two ## $order =~ s[(..)?($key)][$2$1];
## down two ## $order =~ s[($Key)(..)?][$1$2];
return $valByKey{ $key };;
}
##
##
$order = "CABDE";
%valByKey
{ A => \A_value }
{ B => \B_value }
{ C => \C_value }
{ D => \D_value }
{ E => \E_value }