Search Perl pages
Professions, Sciences, Humanities, Business, ...
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...
Conversions, tests, processing, manipulation,...
Integer, Floating point, Matrix, Statistics, Boolean, ...
Algorithms, Memory, Process control, Debugging, ...
Data storage, Integrity, Encryption, Compression, ...
Networks, protocols, Interprocess, Remote, Client Server, ...
Timing, Calendar and Clock, Audio, Video, Printer, Controls...
Management, Filtering, File & Directory access, Viewers, ...
Next: How can I lock a file?
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.
Source: Perl FAQ: Files and Formats
Copyright: Copyright (c) 1997 Tom Christiansen and Nathan Torkington.
Previous: How can I open a file with a leading ">" or trailing blanks?
(Corrections, notes, and links courtesy of RocketAware.com)
Up to: File Information
Search | About | Comments | Submit Path: RocketAware > Perl >
RocketAware.com is a service of Mib Software
Copyright 2000, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments