#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $dir = 'd:\\test'; { 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); }