while () { if ( $. % 2 ) { $gref = (split /\|/, $_)[0]; } else { $type = (split /,/, $_)[0]; } }