use strict; use warnings; my $var = 'abcd,ef,,ghijkl,mnop'; my @matches = split /,/, $var; $_ && print "$_\n" for @matches;