mmfuller has asked for the wisdom of the Perl Monks concerning the following question:
I don't use perl much. I tried to use it to rename some files and I can't get the rename function to work. The problem seems to be file permissions, but even if I use sudo, or chmod the permissions to 755, it still won't work. Does this have something to do with OSX and Darwin? I am running 10.6.2 on an Intel Macbook.
My code (the directory "kennel" contains two files: cat1, cat2):
When run, this code prints the error message (i.e. does not rename files)opendir(DIR,"kennel"); while ($file = readdir(DIR)) { next unless $file =~ /cat/; my $newfile = $file; $newfile =~ s/cat/dog/; rename($file, $newfile) || print "Don't have permission to rename. +\n"; } closedir(DIR);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: rename doesn't work on OSX?
by toolic (Bishop) on Dec 10, 2009 at 02:09 UTC | |
Re: rename doesn't work on OSX?
by GrandFather (Saint) on Dec 10, 2009 at 02:10 UTC | |
Re: rename doesn't work on OSX?
by ikegami (Patriarch) on Dec 10, 2009 at 03:07 UTC | |
Re: rename doesn't work on OSX?
by vitoco (Hermit) on Dec 10, 2009 at 11:59 UTC | |
by mmfuller (Initiate) on Dec 10, 2009 at 15:14 UTC | |
Re: rename doesn't work on OSX?
by desemondo (Hermit) on Dec 10, 2009 at 03:01 UTC |
Back to
Seekers of Perl Wisdom