my $foo = defined($bar) && length($bar) && (($bar =~ /,/) + 1);