>>259
open(IN,"test.txt");
while(<IN>){
  split(/ /,$_);
  print "$#_\n";
}
close(IN);

これでどうかしら?