local $/ = undef; my $names = ; $names =~ /First: (\w+)\nSecond: (\w+)\nThird: (\w+)/; my ( $first, $second, $third ) = ( $1, $2, $3 ); print "$first, $second, $third\n"; __DATA__ First: Bob Second: Me Third: You