use strict; use warnings; my %data; while () { my ($key, $value) = split /\s*=\s*/; if (m/["']([^'"]+)/) { $data{$key} = $1; } } for my $key (keys %data) { print "$key = $data{$key}\n"; } __DATA__ name = "varun" ip='9.12.23.222' #including the irregular spaces