use Data::Dumper; use strict; my %hash; while () { chomp; next unless $_; my @bits = split /: |;/; my $key = shift @bits; $hash{$key} = \@bits; } print Dumper \%hash; __DATA__ t-98: 12;3;56;24 t-56: 1;98 t-3 : 12;56