sub hasher { shift(), (@_ ? $#_ ? { &hasher } : @_ : return) } my %hash; while () { chomp; my @a = hasher(split /=/); $hash{ $a[0] } = $a[1] if @a == 2; } use Data::Dumper; print Dumper \%hash; __DATA__ a = ID = 1234 = this is the next bit = fifteen = 19.168.0.2 <> b=Gadens_Melb c= d= e=2006-03-27 15:10:06 f= ContactSensor:INPUT2 g=Critical h=Event-101 fatal stack error on PRI 001