It is interesting to compare the C++ version with a Perl version!
Code:
while (<*>) {
   $old = $_;
   $_ = lc;
   s/[^a-z0-9.]/_/g;
   rename $old, $_;
}