Thread Ein Katalog-System: Titel und Untertitel (15 answers)
Opened by Gast at 2004-04-18 16:40

renee
 2004-04-19 17:56
#81665 #81665
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Ich habe den Code der Sub mal verbessert und getestet.
Code: (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
sub getPosition{
 my ($arrayref,$title,$position) = @_;
 my @array = @{$arrayref};
 my %hash = ();
 my $ref2hash = ();
 foreach my $index(0..(scalar(@array) - 1)){
   my $type = ref($array[$index]);
   if($type eq 'ARRAY'){
     $position .= '_'.$index;
     $ref2hash = getPosition($array[$index],$title,$position);
     %hash = (%hash,%{$ref2hash});
   }# elsif
   unless($type){
     my $s = $array[$index];
     my $key = $title;
     $key = $key.'_'.$s;
     $key =~ s/\_[^\_]+$/\_$s/ if($index != 0);
     $title = $title.'_'.$s if((ref($array[$index + 1]) eq 'ARRAY') && $index == 0);
     $title =~ s/\_[^\_]+$/\_$s/ if((ref($array[$index + 1]) eq 'ARRAY') && $index != 0);
     my $pos = $position.'_'.$index;
     $title =~ s/^_//;
     $key =~ s/^_//;
     $pos =~ s/^_//;
     $hash{$key} = $pos;
   }# if
 }# foreach
 return \%hash;
}# end getPosition

Die Positionen stimmen eigentlich Vergleiche die Position von
Quote
'Telekommunikation_Festnetz_Telefon_Foo' => '0_1_1_1_0',
und die Ausgabe von
Quote
print $categories->[0]->[1]->[1]->[1]->[0];
\n\n

<!--EDIT|renee|1082383000-->
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/

View full thread Ein Katalog-System: Titel und Untertitel