use strict; use warnings; my $testString = "Test Hallo Test"; if($testString =~ /Hallo/) { my $test =~ /Hallo/; my $myVar = $1; print "true $myVar"; } else { print "false\n"; }