Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################################# 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;
- }
Add Comment
Please, Sign In to add comment