#!perl use warnings; use strict; use Data::Dumper; my $str = "ABC,123,,,,,,XYZ"; my @elems = split ',', $str; print Dumper \@elems;
This gives:
$VAR1 = [ 'ABC', '123', '', '', '', '', '', 'XYZ' ];
It puts an empty string.
Edit: Note that the documentation for split() states that "by default, empty start fields are saved and empty end fields are deleted." Thus, if your string is ABC,123,,,,,,XYZ,,,, then your returned list will be the same as in the above example, but if your string is ,,,,ABC,123 , then you have there will be a list with three blank lines in elements 0, 1 and 2 (in addition to 'ABC' and '123' ).
Edit 2: Try dropping the @matrixDetail and @oldDetail . Probably one of them is not as long as you think. You can also consider checking the number of items in these two lists before trying to use them to make sure you have as many items as you expect.