in reply to Regex frustration

There is probably a better way, but this is tested and does work.

I could get it to eval the value of $1 into $str either.

Using qr// to put your regex into a string save much bother of escaping thing and saves you from needing to eval the regex.

#! perl -sw use strict; my $exp= qr/^DMSC0022\s+\S+\s+(\w+)$/; my $str='Logfile_Connection_Lost Hostname: ?'; $_="DMSC0022 X10 oswald"; if ( m/$exp/) { my $bit = $1; $str =~ s/\?/$bit/; print $str; }

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!