Just one slight problem... $$ is the current program pid, since $1 is not a scalar ref to dereference. It might be better to quote the first $ sign if this behaviour is not desireable (which would have been the cause for half of the original problem as well).
$format_string =~ s/%(\w)/"\$$1"/eeg;
And the second eval can be moved outside.
Comment on Re: Re: Format string and regex question