Advertisement
Guest User

Untitled

a guest
Aug 12th, 2012
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.75 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3.  
  4.  
  5. use strict;
  6. use warnings;
  7. #use diagnostics;
  8. use utf8;
  9. require 'dumpvar.pl';
  10.  
  11. my @aarray;
  12. my %hash;
  13.  
  14. push(@{ $hash{"KEYNAME1"} }, "val11");
  15. push(@{ $hash{"KEYNAME1"} }, "val12");
  16. push(@{ $hash{"KEYNAME1"} }, "val13");
  17. push(@{ $hash{"KEYNAME2"} }, "val21");
  18. push(@{ $hash{"KEYNAME2"} }, "val22");
  19. push(@{ $hash{"KEYNAME2"} }, "val23");
  20.  
  21. print "hash:\n";
  22. dumpValue(\%hash); # { feld => [w1 w2], ... }
  23.  
  24. foreach my $feld (keys %hash) { # [ { feld => [w1 w2] }, ... ]
  25.     my @array;
  26.     foreach my $wert (@ {$hash{$feld}}) {
  27.         print "wert $wert";
  28.         push @array, $wert;
  29.     }
  30.     my %h;
  31.     %h = ( $feld => [ @array ] );
  32.     push @aarray, { %h };
  33. }
  34.  
  35. #print "array:\n";
  36. #dumpValue(\@array);
  37.  
  38. print "aarray:\n";
  39. dumpValue(\@aarray);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement