in reply to Variable in regexp

Are you expecting something like this?
my $var = "only"; my $str = "only_once"; if($str =~ /($var)\_(.*)/) { print "$1\t$2\n"; }