in reply to problem with removing space

do this...
$dir = $ARGV[0]; # get dir from arg list opendir(D, $dir) or die $!; for(readdir(D)) { $file = $_; tr/ /_/; # or tr/ \t\r\n/_/; for tabs and spaces # or s/\s+/_/g; to make multiple whitespace chars into one _ rename("$dir/$file", "$dir/$_"); } closedir(D);
should work nicely...
                - Ant

Replies are listed 'Best First'.
(tye)Re: problem with removing space
by tye (Sage) on Apr 03, 2001 at 21:48 UTC

    Note that you can also use tr to squash multiple whitespace characters into single _s:

    $_= " This is \t a test\cM\n"; tr/ \t\f\r\n/_/s; print; __END__ prints "_This_is_a_test_"

            - tye (but my friends call me "Tye")
      Ahhh... I never got into using tr... just one of those things... I should. So how do you make tr trade one for one?
      tr/ \t\f\r\n/_____/
                      - Ant

        No, you just leave the "s" off the end.

                - tye (but my friends call me "Tye")