NAME File::IgnoreReadonly - Temporarily ensure a file is writable, even if it is readonly SYNOPSIS SCOPE: { # Make writable, if possible (dies on error) my $guard = File::IgnoreReadonly->new( 'readonly.txt' ); # Change the file open( FILE, '>readonly.txt' ) or die "open: $!"; print FILE "New Content"; close( FILE ); } # File is now readonly again DESCRIPTION This is a convenience package for use in situations that require you to make modifications to files, even if those files are readonly. Typical scenarios include tweaking files in software build systems, where some files will have been generated that are readonly, but you need to be able to make small tweaks to them anyways. While it is certainly possible to simply set a file non-readonly (if it is readonly) and then set it back to readonly again afterwards, doing this in many places can get laborious and looks visually messy. File::LexWrite allows for the creation of a simple guard object that will ensure a file is NOT set readonly (across multiple different operating systems). When the object is DESTROY'ed at the end of the current scope, the file will be returned to the original file permissions it had when the guard object was created. METHODS new The "new" method is a simple constructor that takes a single parameter. It will set the file to writable if needed, and return a guard object. When the guard object is DESTROYed, the file will be set back to the original file mode. Returns a new File::IgnoreReadonly object, or throws an exception (dies) on error. SUPPORT Bugs should be reported via the CPAN bug tracker at For other issues, or commercial enhancement or support, contact the author. AUTHOR Adam Kennedy COPYRIGHT Copyright 2008 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module.