Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Re: Re: how to rename all files in a dir

by jjohn (Beadle)
on Jul 07, 2002 at 13:04 UTC ( #179964=note: print w/replies, xml ) Need Help??

in reply to Re: Re: how to rename all files in a dir
in thread how to rename all files in a dir

If so, how often, relative to the times when you do?

While I share your pain (and frequently stumb my toe on this behavior), I think this idiom will help you. Use the chdir() function to get to the desired directory, then read away. That way, your can use the result of readdir directly.

use CWD; my $org_dir = cwd; chdir($desired_dir) || die "can't cd: $!"; opendir(DIR, $desired_dir) || die "can't opendir: $!"; while(my $file = readdir DIR){ next if -d $file; # preform operations below on $file } closedir DIR; chdir($org_dir) || die "can't get back to $org_dir: $!";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://179964]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2020-04-10 06:57 GMT
Find Nodes?
    Voting Booth?
    The most amusing oxymoron is:

    Results (49 votes). Check out past polls.