while () { chomp; (my ($first, $second) = split /:/) == 4 or next; print "$first $second\n"; } __DATA__ dog:cat:pig Amy:Ann ape:ant:bug:car