use Modern::Perl; use Text::CSV_XS; use Data::Dumper; my $csv = Text::CSV_XS->new({ sep_char=> "," }); #normally this would be a real file handle my $line = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; open my $fh, "<", \$line; my $row = $csv->fragment($fh, "col=1;3;10-12;23-*"); print Dumper($row);