On Mon, Jan 14, 2002 at 12:44:34PM -0500, Yacketta, wrote:
> Folks,
> 
> I am reading in a .cfg file and exclude comments (#) and spaces at the
> beginning of the line
> how would I lop off any comments in a line?
> 
> IE:
> 
> Key "value" # comment here
---end quoted text---

while(<CONFIG>){
        next if /^\s*(#.*)?$/;  # Skip it if just comment or blank
        s/#.*$//;               # remove comments
        ($key,$value)=split/\s+/,$_,2; # Get exactly two values out
        $config{$key}=$value;   # Load into a hash for use.
}

-- 
 Frank Booth - Consultant
Parasol Solutions Limited.
(www.parasolsolutions.com)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to