my ($x,$y) = ($text =~ /.*(START (.*) END)$/)[0,1]; print "x=$x y=$y\n"; #prints: x=START only text I want END y=only text I want