use strict; use warnings; while (my $line = ) { #remove all whitespace $line =~ s/\s//g; #split line my @aFields = split(/;/, $line); #remove parenthesised field my $sFld1 = shift @aFields; #convert parenthesized field to numbers my ($sNoParens) = ($sFld1 =~ /^\(([^)]*)\)$/); my @aSubFields = split(/,/, $sNoParens); # if you want to make sure there are only N # numbers, do your checks here. #put the numbers where fld0 was originally unshift @aFields, @aSubFields; #print the result print "<@aFields>\n"; } __DATA__ ( 0, 670); 3.2; 7.8; 9.4; 10.2; 12.6;