$ cat foo.pl use strict; use warnings; my $x; my $y; while () { chomp; (2==0+(($x, $y) = split /:/,$_)) or print "wrong number of fields\n"; print "<$_>, <$x>, <$y>\n"; } __DATA__ FOO:BAR:BAZ:PLOVE FOO:BAR:BAZ FOO:BAR BAZ $ perl foo.pl wrong number of fields , , wrong number of fields , , , , wrong number of fields Use of uninitialized value $y in concatenation (.) or string at foo.pl line 7, line 4. , , <>