my $string = '4,5, ,, ,6,,,'; should give after spliting: @splited == (4, 5, 6)