07 Jul 2009 16:06:11 UTC
- Distribution: File-LocalizeNewlines
- Module version: 1.12
- Source (raw)
- Browse (raw)
- How to Contribute
- Clone repository
- Issues (4)
- Testers (1606 / 3 / 1)
- KwaliteeBus factor: 1
- 77.89% Coverage
- License: perl_5
- Perl: v5.5.0
- Activity24 month
- Download (28.38KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionADAMK Adam Kennedy
File::LocalizeNewlines - Localize the newlines for one or more files
For people that routinely work with a mixture of different platforms that have conflicting newline formats (mainly *NIX and Win32) there are a number of different situations that can result in files having their newlines get corrupted.
File::LocalizeNewlines provides a mechanism for one off or bulk detection and conversion of these files to the newline style for the local platform.
The module implements the conversion using a standard "universal line seperator" regex, which ensures that files with any of the different newlines, plus a couple of common "broken" newlines, including multiple different types mixed in the same file, are all converted to the local platform's newline style.
newconstructor creates a new conversion object.
By default, the conversion object will process all files and convert them to the local platform's newline format.
Takes some optional parameters
- filter => File::Find::Rule
filterparam allows you to provide an instantiate File::Find::Rule object, that will used to determine the list of files to check or process.
- newline => $newline
newlineoption allows you to provide an alternative newline format to the local one. The newline format should be provided as a literal string.
For example, to force Win32 newlines, you would use
my $Object = File::LocalizeNewlines->new( newline => "\015\012" );
- verbose => 1
verboseoption will cause the
File::LocalizeNewlinesobject to print status information to
STDOUTas it runs.
Returns a new
Findaccessor returns the File::Find::Rule object that will be used for the file search.
newlineaccessor returns the newline format that will be used in the localisation process.
localizedmethod takes an argument of a single file name or file handle and tests it to see it is localized correctly.
Returns true if localized correctly, false if not, or
findmethod takes the path for a dir (or file) and returns a list of relative files names for all of the files that do not have their newlines correctly localized.
Returns a list of file names, or the null list if there are no files, or if an incorrect path was provided.
localizemethod takes a file, file handle or directory as argument and localizes the newlines of the file, or all files within the directory (that match the filter if one was provided).
Returns the number of files that were localized, zero if no files needed to be localized, or
Bugs should always be submitted via the CPAN bug tracker
For other issues, contact the maintainer.
Adam Kennedy <firstname.lastname@example.org>
Thank you to Phase N (http://phase-n.com/) for permitting the open sourcing and release of this distribution.
FileHandle support added by David Dick <email@example.com>
Copyright 2005 - 2009 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.
Module Install Instructions
To install File::LocalizeNewlines, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install File::LocalizeNewlines
For more information on module installation, please visit the detailed CPAN module installation guide.