#!perl use warnings; use strict; use Data::Dumper; my $str = "ABC,123,,,,,,"; # just ABC and 123 #my $str = "ABC,123,,,,,,this"; # now it shows the blanks. my @elems = split ',', $str; print Dumper \@elems;