Thread Ausschneiden & Sortieren (7 answers)
Opened by thomase at 2006-05-09 15:57

renee
 2006-05-09 16:22
#65800 #65800
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Das koennte ungefaehr so gehen:
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 strict;
use warnings;
use Data::Dumper;

my $dir = '/path/to/directory';
{
opendir(DIR,$dir) or die $!;
my @files = grep{$_ !~ /\.?\./}readdir(DIR);
closedir DIR;

local $/ = "\nFeld";
my @array;
for my $file(@files){
my %hash;
open(my $fh,'<',$file) or die $!;
while(my $line = <$fh>){
chomp $line;
my ($nr) = $line =~ /^\s*(\d+)/;
$hash{$nr} = $line;
}
close $fh;
push @array,\%hash;
}

@array = sort{$a->{1} cmp $b->{1}}@array;
}

print Dumper(\@array);
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 Ausschneiden & Sortieren