use strict; use warnings; use Data::Dumper; my %data = map { s/#.*//; # remove comments s/^\s+//; # remove leading white space s/\s+$//; # remove trailing white space m/(.*?)\s*=\s*(.*)/; # split on =, ignoring surrounding spaces } ; print Dumper(%data); __DATA__ NAME=John Smith AGE=15 RANK=Tier 1 URL=http://somesite.com