sub csv_split { local $_ = shift || return undef; my @array = (); my $count = my $quoted = 0; while ( s/(.)// ) { if ($1 eq ',' && !$quoted) { $count++; next; } if ($1 eq q/"/) { unless ( $quoted && s/^\"// ) { $quoted = 1 - $quoted; next; } } $array[$count] .= $1; } @array; }