my $re = qr/(3_prtnm_|2_prtnm_|2_mrslt_)/; # ... while( my $line = ) { if( m/$re/ ) { my $sep = $1; my @tmp = split( /$sep/, $line ); # ... } }