Thread Hash von Hashes einstiegsprobleme (19 answers)
Opened by v0id at 2007-03-12 18:01

renee
 2007-03-12 19:35
#74956 #74956
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Wie wär's mit
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
31
32
33
34
35
36
37
38
39
40
41
#!/opt/perl5.8.6/bin/perl -w

use Time::Local;

my $dir = "/pfad/";
my $oldname = 0;

my %dif_hash;

opendir(DIR, "$dir");
my @files = readdir(DIR);
closedir(DIR);

print "Inhalt von $dir:\n";

foreach my $file (@files) {
#auszulesendedatei.20070117.001124.log
my @info = $file =~ m/(.*)\.(\d{4})(\d{2})(\d{2})\.(\d{2})(\d{2})(\d{2})\.log/;

if ( $info[0] ne $oldname )
{
my %subhash = ();
@subhash{ qw/name year month day hour minute second/ } = @info;
$div_hash{ $info[0] } = {
begin => { %subhash }
};
}
else
{
my %subhash = ();
@subhash{ qw/name year month day hour minute second/ } = @info;
$div_hash{ $info[0] } = {
end=> { %subhash }
};
}

$oldname = $1;

}

print Dumper(\%div_hash);
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 Hash von Hashes einstiegsprobleme