{ local $/ = undef; my $names = ; } #$/ is back to our original record separator #(which you can use in the regexp if you want) e.g. if ( $names =~ m|First: (\w+)$/Second: (\w+)$/Third: (\w+)|s ) { .... }