use warnings; use strict; my @file_array = qw(a|b|c d|e|f); foreach my $row (0 .. @file_array - 1) { foreach my $column (split /\|/, $file_array[$row]) { print "$row $column\n"; } } __END__ 0 a 0 b 0 c 1 d 1 e 1 f