Thread new_hash = old_hash ....desaster: Hash bekommt Elemente übertragen,...
(3 answers)
Opened by xeroxed_yeti at 2007-07-19 12:30
Das kannst Du so lösen:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 #/usr/bin/perl -w use strict; use warnings; use Data::Dumper; #print `clear`; my @valuesNode1 = ( ['red1','GO:001'], ['red2','GO:002'], ['red3','GO:003'] ); my @valuesNode2 = ( ['blue1','GO:001'], ['blue2','GO:004'] ); my %nodeRelation1 = _get_base(); foreach my $ref (@valuesNode1) { my $value = $ref->[0]; my $id = $ref->[1]; if (exists $nodeRelation1{$id}) { ${$nodeRelation1{$id}}[0]++; push (@{$nodeRelation1{$id}}, $value); } } print "\n"; foreach my $key (sort keys %nodeRelation1) { print "nodeRelation1: $key\t",$nodeRelation1{$key},"\n";#@tmp\n"; } print "\n"; my %nodeRelation2 = _get_base(); foreach my $ref (@valuesNode2) { my $value = $ref->[0]; my $id = $ref->[1]; if (exists $nodeRelation2{$id}) { ${$nodeRelation2{$id}}[0]++; push (@{$nodeRelation2{$id}}, $value); } } print "\n"; foreach my $key (sort keys %nodeRelation2) { print "nodeRelation2: $key\t",$nodeRelation2{$key},"\n";#@tmp\n"; } print "\n"; sub _get_base{ my %nodes = ( 'GO:001' => [0], 'GO:002' => [0], 'GO:003' => [0], 'GO:004' => [0] ); return %nodes; } OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |