#!/usr/local/bin/perl use strict; use warnings; use Time::Local; use POSIX qw(strftime); my %flights; while ( my $line = ) { chomp $line; my ( $date, $num, $to, $from, $char, @times ) = split / /, $line; my $text = "$num $to $from $char"; my ( $mday, $mon, $year ) = split /\./, $date; for my $time (@times) { my ( $hour, $min ) = split /:/, $time; my $epoch = timelocal( 0, $min, $hour, $mday, $mon, $year ); push @{ $flights{$epoch} }, $text; } } for my $key ( sort keys %flights ) { my $time = strftime "%a %b %e %H:%M %Y", localtime($key); for my $flight ( @{$flights{$key}} ) { print "$time - $flight\n"; } } _ _DATA_ _ 30.07.2004 123456 Malaga Bielefeld C 12:15 11:31 23.07.2004 654321 Berlin Bielefeld D 13:00 12:58 04.07.2004 587931 Barcelona Bielefeld E 14:00 12:00 30.07.2004 356987 Muenchen Bielefeld A 12:50 12:00 30.07.2004 879652 Koeln Bielefeld B 12:55 12:15 30.07.2004 456987 Bonn Bielfeld H 14:00 11:55 05.08.2004 456789 Freiburg Bielfeld C 15:00 13:00 01.09.2004 336632 Berlin Bielefeld B 22:00 19:00