I saw your post on the perl-beginners list, but deleted it, so I was hoping someone else would reply and I could work off that, so I'm glad you posted it here, too.

Here's my take:

# parse variable assignments out of the file while ($ebuildcontents =~ /\b([-A-Z0-9_]+)=\"(.*?)\"{1}?/sgc) { $ebuildvars{$1} = $2; }
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:
foreach (keys %ebuildvars) { $ebuildvars{$_} =~ s/\$\{?([-A-Z0-9_]+)\}?/$ebuildvars{$1}/gs; }
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?

If so, let me know, and I'll help you write a solution. It's kind of related to a dependency tree...

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

In reply to Re: simulating bash by japhy
in thread simulating bash by agaffney

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.