perl -e 'print+(sort{$b<=>$a}map{length}<>)[0]' file
perl -lpe '$_=(sort{$b<=>$a}map{length}<>)[0]' < foo