my $text = "Hallo\nWelt.\n"; if ( $text =~ m/^(.*?)$(.*)/sm ) { print "[$1]\n[$2]\n"; }