> perl -wl
my ($x,$y,$z) = ('','','');
($x,$y,$z) = split(',','a,b');
print "$x $y $z";
__END__
Use of uninitialized value in concatenation (.) or string at - line 3.
a b
> perl -wl
my ($x, $y, $z) = map { $_ || '' } split(',', 'a,0,b');
print "$x $y $z";
__END__
a b
The second one is easily fixed with:
perl -wl
my ($x, $y, $z) = map defined $_ ? $_ : '', (split(',', 'a,0,b'))[0..2
+];
print "$x $y $z";
__END__
a 0 b
Update: Doh! Thanks !1 (silly lurker).
antirice The first rule of Perl club is - use Perl The ith rule of Perl club is - follow rule i - 1 for i > 1
|