Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

How can I reliably rename a file?

by faq_monk (Initiate)
on Oct 13, 1999 at 03:42 UTC ( #803=perlfaq nodetype: print w/replies, xml ) Need Help??

Current Perl documentation can be found at perldoc.perl.org.

Here is our local, out-dated (pre-5.6) version:

Well, usually you just use Perl's rename() function. But that may not work everywhere, in particular, renaming files across file systems. If your operating system supports a mv(1) program or its moral equivalent, this works:

    rename($old, $new) or system("mv", $old, $new);

It may be more compelling to use the File::Copy module instead. You just copy to the new file to the new name (checking return values), then delete the old one. This isn't really the same semantics as a real rename(), though, which preserves metainformation like permissions, timestamps, inode info, etc.

The newer version of File::Copy export a move() function.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Corion]: And I also have to talk to the technician implementing the export side of the change that this is not about them, and that maybe they should hold on to that changeset just in case the project comes back with a formally correct approach...
[Corion]: Naah - I think the "fasta" format should be familiar by now to the casual visitor of this site ;)
[Corion]: The rest would benefit from de-jargonizing. Maybe somebody versed in both, Perl and bioinformatics could write up a translation dictionary ;)
[marto]: I helped with some corrections to the Glasgow Uni Perl for Bioinformatics course, but didn't get time to do a full review. I've also patched some trivial problems with the bioperl based upon a question someone asked here.
[marto]: but I've never done any bioinformatics work, so don't know what people are talking about :P
[marto]: Corion biohisham & BioLion seem long gone
[marto]: IIRC BrowserUK understands this stuff

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-08-17 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (285 votes). Check out past polls.

    Notices?