my $a = "important value"; # open flatfile here... # use index and substr to find macro strings delimited with <% ... %> # loop through found macros eval($macro) # replace macro code with eval value # print resulting text # keep using variable $a, expecting the value will still be "important value"...