smackdab has asked for the wisdom of the Perl Monks concerning the following question:
while (<CONFIG>) { if (/^\s*#/) { # ignore comment line } elsif (/^\s*$/) { # ignore blank line } elsif (/(\w+)\s*=\s*[<]{2}(\w+)/) { # heredoc (my $name, local $/) = ($1, "\n$2"); # ++ysth $config{$name} = <CONFIG>; chomp $config{$name}; # as etcshadow points out. } elsif (/(\w+)\s*=\s*(.*?)\s*$/) { # regular pair $config{$1}=$2; } else { warn "Ptooey: Could not parse config line: $_\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: addn'l help with parsing here doc
by graff (Chancellor) on Oct 17, 2003 at 03:29 UTC | |
|
Re: addn'l help with parsing here doc
by etcshadow (Priest) on Oct 17, 2003 at 03:46 UTC |