use strict; use warnings; use Data::Dumper; my @parsed = (); while () { my $in = $_; chomp($in); my @line = split(/,/, $in); for my $i(0..$#line) { $parsed[$i] .= $line[$i].'|'; } } map {chop} @parsed; print Dumper(\@parsed); __DATA__ 123,"text",66,"more text" 124,"text1",67,"more text1" 125,"text2",68,"more text2"