use strict; use warnings; use Data::Dumper; my %x = ('period' => "2010/05", 'type' => "voice", 'tcon' => "A,B", 'hcon' => "Z,T,A" ); # extract out the value, which is a string my $string = $x{'hcon'}; # split the string my (@array) = split /,/,$string; # sort the elements my (@sorted) = sort @array; # recreate string with sorted elements my $new_string = join (",",@sorted); # store back into the hash $x{'hcon'} = $new_string; print Dumper($x);