#while() { while ($question =~ /([a-zA-Z0-9.-_]+)\/([A-Z]+)/g){ $word = $1; $tag = $2; print OUT "$tag"."/"; print "$word"."/"; } print OUT "\n";