in reply to Regex to replace $vars with subroutine

Update: Put $page through two passes of string interpolation.

$galleryname = galleryname(); $page = eval "qq{$page}";

It struck me right away that your $var placeholders are just begging to be interpolated.

If gallery() returns 'the Rijksmuseum' and $page is 'Welcome to $gallery!', then eval will see qq{Welcome to $gallery} and $page will get 'Welcome to the Rijksmuseum!'