in reply to Sorting the hash
First, please put your code in <c></c> tags.
I didn't test the code below, but it should do the trick. It probably isn't very efficient or elegant, but it does illustrate each logical step. I'm sure others will be able to do it with fewer lines of code.
use strict; use warnings; use Data::Dumper; my %x = ('period' => "2010/05", 'type' => "voice", 'tcon' => "A,B", 'h +con' => "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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting the hash
by AnomalousMonk (Archbishop) on Oct 04, 2010 at 17:11 UTC | |
by tinita (Parson) on Oct 05, 2010 at 08:03 UTC | |
|
Re^2: Sorting the hash
by annem_jyothsna (Initiate) on Oct 04, 2010 at 10:37 UTC | |
by Utilitarian (Vicar) on Oct 04, 2010 at 11:02 UTC | |
by eyepopslikeamosquito (Archbishop) on Oct 04, 2010 at 11:03 UTC | |
by halfcountplus (Hermit) on Oct 04, 2010 at 11:06 UTC | |
by annem_jyothsna (Initiate) on Oct 04, 2010 at 11:12 UTC |