in reply to simulating bash
Here's my take:
I'm curious about your \"{1}? part there. Are quotes optional? I'd need to see how the config file is formatted, to help you extract these variables appropriately. But let's move onto the troublesome part:# parse variable assignments out of the file while ($ebuildcontents =~ /\b([-A-Z0-9_]+)=\"(.*?)\"{1}?/sgc) { $ebuildvars{$1} = $2; }
The problem is that if VAR1 = "say $VAR2" and VAR2 = "hi $VAR3" and VAR3 = "jeff", you want to be able to expand ALL of these, so you get VAR1 = "say hi jeff", VAR2 = "hi jeff", and VAR3 = "jeff", right?foreach (keys %ebuildvars) { $ebuildvars{$_} =~ s/\$\{?([-A-Z0-9_]+)\}?/$ebuildvars{$1}/gs; }
If so, let me know, and I'll help you write a solution. It's kind of related to a dependency tree...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: simulating bash
by agaffney (Beadle) on May 13, 2004 at 15:21 UTC | |
by japhy (Canon) on May 13, 2004 at 15:42 UTC | |
by agaffney (Beadle) on May 13, 2004 at 17:11 UTC | |
by japhy (Canon) on May 13, 2004 at 18:32 UTC | |
by agaffney (Beadle) on May 13, 2004 at 19:22 UTC | |
| |
by agaffney (Beadle) on May 13, 2004 at 16:38 UTC |