in reply to Re: split line and populate hash shortcut ?
in thread split line and populate hash shortcut ?
You could even write this as:my %config; m[^([^#][^=]+)=(.*)$] and $config{ $1 } = $2 while <DATA>;
There is an example somewhere in the perldocs that gives essentially the same technique for parsing simple config files, though I can't find it right now. I always thought it was ingenius & wonderfully succinct. It certainly applies nicely here.my %config = map { /^([^#][^=]+)=(.*)$/ } <DATA>;
blokhead
|
|---|