SPUG: parsing a config file

Andrew Sweger andy at n2h2.com
Sat Jan 8 14:57:05 CST 2000


Oh, Lord of the Little People, I now see the error of my ways.

undef $/;

my $line = <DATA>;
$line =~ s/=/=>/g;
$line =~ s/\;/\,/g;
$line =~ s/\(\)/""/g;
$line .= ";";
my $Config = eval $line;

I used an empty string in place of the empty list instead of a ref to
list.

Get a real network connection, Monkey Boy. %)

On Jan 8, 2000 @ 12:42pm, El JoPe Magnifico wrote:

> Not quite right, Mr. Sluggo!  The trailing comma between the two closing
> curly brackets does no harm.  Look closer below, specifically the value for
> $Config->{'Domain'}{'servers'} ...parentheses, rather than square brackets!
> Because => is syntactically the same as a comma, that empty list collapses
> in on itself, leaving you with three items in the list being assigned to
> the %{$Config->{'Domain'}} hash, efffectively making the assigment...
> 
> 	Domain => {
> 		servers => status,
> 		Enabled =>
> 	}
> 
> Hence the error below.  My connection keeps dogging out on me, so I'll
> leave it to someone else to add the line(s) to convert the parenthese to
> square brackets.

-- 
  Andrew Sweger <andy at n2h2.com>  |  N2H2, Incorporated
  v=206.336.2947 f=206.336.1541  |  900 Fourth Avenue, Suite 3400
     Advanced Technologies       |  Seattle WA 98164-1059
          Development            |  http://www.n2h2.com/



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list