C:\test>type fred.pl $exp = qr|^DMSC0022\s+\S+\s+(\w+)$|; $str = 'Logfile_Connection_Lost Hostname: $1'; # note that you have to use single quotes or the $1 is interpolated as soon as you de fine $str, not when you eval() the string (which is completely superfluous) $_ = "DMSC0022 X10 oswald"; if ($exp) { print eval $str; # *now* get $str to interpolate } C:\test>fred Use of uninitialized value in print at C:\test\fred.pl line 6. C:\test>