sub parse_cfg_lines { my ($input) = @_; return undef if !defined($input) || $input eq ''; my @ary = split(/\n/, $input); my @out; foreach my $line (@ary) { chomp($line); # get rid of \n if present $line =~ s/\r//g; my %hash = ('commented' => 0); next if ($line =~ /^\s*$/); # ignore blank lines $hash{'commented'} = 1 if ($line =~ /^\s*;/); return undef if ($line !~ /([^ \t;=>]+)\s*=>?\s*(.*)/); $hash{'var_name'} = $1; $hash{'var_val'} = $2; push(@out, \%hash); } \@out; }