Thread Dateipfade hierarchisch in Hash speichern. (5 answers)
Opened by DocJones at 2010-08-28 16:26

DocJones
 2010-08-28 16:26
#140997 #140997
User since
2010-08-28
3 Artikel
BenutzerIn
[default_avatar]
Hallo,
ich möchte aufgelistete Dateipfade in einenm HAsh Speichern.
Ich habe schon folgenden code:

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
29
30
#!/usr/bin/perl
use Data::Dumper;

@arr = (
'/usr/bin/local',
'/usr/bin/local/fff',
'/usr/bin/locale/abc',
'/usr/bin/locale/etc',
'/usr/bino/local',
'/usr/bino/local',
'/usr/bino/local/ssss'
);


my @resultset;
my $count = 0; #Laege des laengsten elemenst des Arrays

foreach(@arr){
my @a = split('/',$_);
if($#a > $count){
$count = $#a;
}
}

foreach(@arr){
my @a = split('/',$_);
push @resultset, $resultset[0]->{$a[1]}->{$a[2]}->{$a[3]}->{$a[4]} = {};
}

print Dumper($resultset[0]);


Die Ausgabe passt auch schon nur ist das Speichern in den Hash nicht dynamisch.

Hoffe auf eure Hilfe.
Last edited: 2010-08-28 16:43:12 +0200 (CEST)

View full thread Dateipfade hierarchisch in Hash speichern.