in reply to Parsing a config file
while (my @CFG = <CFGFILE>) { foreach $_(@CFG) { ... } print ... }
is the same thing as
my @CFG = <CFGFILE>; foreach $_(@CFG) { ... } print ...
since <FILE> returns the entire file as a list of lines when used in a list context.
Change
while (my @CFG = <CFGFILE>) { foreach $_(@CFG) { ... } print ... }
to
while (<CFGFILE>) { ... print ... }
to fix the problem.
Update: You may have other problems; I didn't look deeper. Check out dragonchild's XML suggestion (which I meant to mention myself) and the code he supplied for something better.
|
|---|