my $regex = "\$file =~ s/\\\$$variable/$path/g;"; eval "$regex";