Perl can:
perl -le \'$d=1; while(1){ $d/=2 and ++$i or last } print "i=$i"\'
But not:
perl -le \'$d=1; $d/=2 and ++$