#!/usr/bin/perl -w
# -----------------------------------------------------------
#	fillspaces
#
#  Usage: fillspaces [files] [dirs]
#
#  rename any files or directories that contain
#   spaces (from a Windows copy) with an underscore.
# 
# --------------------------------------------------------------

use File::Find;                       # load find module 

@ARGV = ('.') unless @ARGV;           # no args? use CWD to start
                                      # need ()s since array context.
find (\&Fill,@ARGV);                  # actual find that calls testem
                                      # pass ref to function, and dirs

# ----------------------------------
sub Fill {                            # function to use with find
  
  if ($_ =~ / /) {
     chomp $_;

     ($new = $_) =~ s/ /_/g;   # set new and modify
     print " rename $_, $new\n";
     rename ($_, $new)    or   warn "Cannot rename $_\n";
  }
}

 
# ---------------------------------------------------------------








