On Tue, 07 May 2002 09:11:23 +0100, Simon Oliver wrote:
>Michael Blackmore wrote:
>> I am trying to avoid doing the following on 80 columns
>>
>> ....
>> my ($col1,$col2,.....) = split(/,/);
>> $col1 = undef unless($col1);
Turning 0 into undef is OK? I think not.
>> ....
>
>How about using map to do it for you?
Not a bad idea...
>my @Fields = map {defined($_) ? $_ : undef} split(/,/);
But this has zero effect. You're turning undef into undef. There is no
undefined value to begin with.
my @Fields = map { length() ? $_ : undef} split(/,/);
--
Bart.