Created
July 8, 2010 19:04
-
-
Save jevinskie/468443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################# HELPERS ################################### | |
############################################################################### | |
## Function : unmarshal ( ) | |
## ---------------------------------------------------------------------------- | |
## Description : | |
## unserialize transform array into hash, but keys are not ordered anymore | |
## unmarshal does the unserialize, reorder and return an array | |
## Parameters : | |
## Return : | |
############################################################################### | |
sub unmarshal { | |
my $AA = shift; | |
my @CC = (); | |
my $BB_ref = unserialize($AA); | |
my @BB_keys = sort keys %$BB_ref; | |
foreach(@BB_keys) { | |
push @CC, $BB_ref->{$_}; | |
} | |
return @CC; | |
} | |
############################################################################### | |
## Function : unmarshal2 ( ) | |
## ---------------------------------------------------------------------------- | |
## Description : | |
## same as unmarshal but with depth 2 | |
## Parameters : | |
## Return : | |
############################################################################### | |
sub unmarshal2 { | |
my $AA = shift; | |
my @CC = (); | |
my $BB_ref = unserialize($AA); | |
my @BB_keys = sort keys %$BB_ref; | |
foreach(@BB_keys) { | |
my @DD = (); | |
my $values_ref = $BB_ref->{$_}; | |
my @values_keys = sort keys %$values_ref; | |
foreach(@values_keys) { | |
push @DD, $values_ref->{$_}; | |
} | |
push @CC, [@DD]; | |
} | |
return @CC; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment