#!/usr/bin/perl use strict; use warnings; use Slurp; use Data::Dumper; my @lines = slurp('file.txt') or die; my $h = {}; my ($name, $from, $to ); for ( @lines) { next if /^$/; s/\s+//g; ( $name, $from, $to ) = /(\w+) : (\d{2,}) \w+? (\d{2,})/xms; $h->{$name}{'from'} = $from unless defined $h->{$name}{'from'}; $h->{$name}{'from'} = $from if $from < $h->{$name}{'from'}; $h->{$name}{'to'} = $to unless defined $h->{$name}{'to'}; $h->{$name}{'to'} = $to if $to > $h->{$name}{'to'}; } print Dumper($h);