in reply to How can I opendir, replace all files containing a space with .?

Single-character substitution is usually easiest with tr:

my ($filename, $newfile); foreach $filename (readdir(DIR)) { ($newfile = $filename) =~ tr/ /./; rename($filename, $newfile); }
As a bonus, this will replace every space with a period. (That is a bonus, right? ;-)

Also, you want to either chdir to the target directory, or prepend the directory name to the file names. When possible, I prefer chdir:

chdir $dir or die "Can't chdir to $dir: $!\n"; opendir(DIR, '.') or die "Can't open '.': $!\n";

HTH