in reply to CSV Files With Missing Values

Hi. I second previous suggestion that parsing a CSV row 'by hand' is not a good idea, unless you're *sure* there won't be any funny business in the source file (ie. quoted values, commas as part of values).

If you are sure, you can do it 'your' way by amending your split to include the following map to can convert any empty strings to zeroes on the way through.

my ($server, @data) = map { $_ eq '' ? 0 : $_; } split /,/;
The contents of the map is a simple ternary which tests each value for an empty string, replaces it with zero if it matches, or else passes the value through unmolested otherwise.

If your source data might contain trailing empty fields, and you don't want split to silently ignore them, you might also want to give split a limit of -1, like so:

my ($server, @data) = map { $_ eq '' ? 0 : $_ } split /,/, $_, -1;