[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Why do I get an error using 'rename'?



On Fri, Nov 12, 1999 at 08:03:18PM -0500, schinder@pobox.com wrote:
} On Fri, Nov 12, 1999 at 04:45:29PM -0800, Robert Terwilliger wrote:
} } Hi people.  I am trying to remove the '.out' suffix from each file in my
} } directory.  Here is my code:
} } 
} } opendir(DIR, ':::healthcare.ucla.edu:pls:') or die 'cannot open directory';
} } @files = readdir(DIR);
} } closedir(DIR);
} } 
} } foreach $file (@files)
} } {
} }     if ($file =~ m/.out/)
} }     {
} }         ($temp = $file) =~ s/.out//;
} }         rename ($file, $temp) or warn "Could not rename $file to $temp\n";
} }     }
} } } 
} } 
} } ###########################
} } 
} } This is MacPerl console output:
} } 
} } # Could not rename acne.htm.out to acne.htm
} } # Could not rename ageskin.htm.out to ageskin.htm
} } # Could not rename arthritis.htm.out to arthritis.htm
} } # Could not rename asthma.htm.out to asthma.htm
} } 
} } 'rename' is returning 0 and not 1.  How do I get this to work?
} 
} It looks as if you might be trying to rename things on a volume that's
} network mounted.  Do you have write permission to the volume in
} question?  This smells like a classic permissions problem, although
} that might just be my Unix instincts misdirecting me.

Wait, I take it back.  It's much more likely to be the classic problem
with readdir, it returns filenames in the directory that you specify
but doesn't automatically change to that directory.  You're trying to
rename files in the wrong folder.  Try changing the rename to

rename (":::healthcare.ucla.edu:pls:$file", ":::healthcare.ucla.edu:pls:$temp") or warn "Could not rename $file to $temp\n";

} 
} } 
} } --
} } Robert Terwilliger, M.S.
} } raterwil@ucla.edu
} } 
} 
} -- 
} Paul Schinder
} schinder@pobox.com
} 
} # ===== Want to unsubscribe from this list?
} # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org
} 

-- 
Paul Schinder
schinder@pobox.com

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org