use warnings; use strict; my @horiz = ; chomp(@horiz); my @dates = split '\|', shift @horiz; splice @dates, 0, 3; for my $line (@horiz) { my @flds = split '\|', $line; shift @flds; my $PID = shift @flds; my $SID = shift @flds; my @dates_copy = @dates; for my $date (@dates_copy) { print "$PID|$SID|",shift(@flds),"|$date\n"; } } # for $line