#!/usr/bin/perl -w use strict; my $substitution = '$line =~ '.; my $line = "abcdef"; eval $substitution; print $line; __DATA__ s/abc(\w+)f/xxx$1x/;