while () { chomp; my @array = /([^" ]+|"[^"]*")/g; foreach (@array) { # strip quotes s/^"//; s/"$//; print "'$_'\n"; } print "\n"; } __DATA__ "72 3267S" "S2079" 1 no "72 0250" "S3011" 1 no "72 8351S" "S6101" 1 no "72 17082S" "S6108" 1 no __OUTPUT__ '72 3267S' 'S2079' '1' 'no' '72 0250' 'S3011' '1' 'no' '72 8351S' 'S6101' '1' 'no' '72 17082S' 'S6108' '1' 'no'