File::...wlines(3pm)

πŸ“¦
version 1.12 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

File::LocalizeNewlines β€” bestie, it localizes the newlines for one or more files πŸ’… (this is the File::...wlines(3pm) page, yes the name got cut off, we're not gonna talk about it 🫢)


πŸ’– DESCRIPTION πŸ’–

okay so picture this: you're out here living your life, routinely working with a mixture of different platforms that have conflicting newline formats (mainly *NIX and Win32) β€” and there are, like, a whole bunch of different situations that can result in files having their newlines get corrupted. 😭 the drama. the absolute chaos.

File::LocalizeNewlines said "not on my watch" and 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. no cap, all of them. πŸ’…


πŸŽ€ METHODS πŸŽ€

🌸 new param => value, ...

The new constructor creates a new conversion object. iconic behaviour honestly.

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 β€” the filter param lets you hand over an instantiate File::Find::Rule object, that will used to determine the list of files to check or process. (yes, that's the original wording, we keep it fr fr)
  • newline => $newline β€” the newline option lets you 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 β€” the verbose option will cause the File::LocalizeNewlines object to print status information to STDOUT as it runs. she's chatty and we love that for her πŸ’¬

Returns a new File::LocalizeNewlines object. 🫢

πŸ¦‹ Find

The Find accessor returns the File::Find::Rule object that will be used for the file search. πŸ”

πŸ’œ newline

The newline accessor returns the newline format that will be used in the localisation process. slay.

⭐ localized $file

The localized method 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 undef on error. πŸ™ˆ

🌈 find $dir

The find method 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. lowkey a snitch, highkey useful.

Returns a list of file names, or the null list if there are no files, or if an incorrect path was provided.

πŸ‘‘ localize $file | $dir

The localize method 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). main character energy, doing the actual work πŸ’…

Returns the number of files that were localized, zero if no files needed to be localized, or undef on error.


πŸ› SUPPORT πŸ›

Bugs should always be submitted via the CPAN bug tracker:

<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-LocalizeNewlines>

For other issues, contact the maintainer. 🫢


✨ AUTHOR ✨

Adam Kennedy <adamk@cpan.org>


🌸 ACKNOWLEDGEMENTS 🌸

Thank you to Phase N (<http://phase-n.com/>) for permitting the open sourcing and release of this distribution. absolute icons, truly. πŸ™

FileHandle support added by David Dick <ddick@cpan.org> β€” thank you bestie πŸ’–


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.


ok that's the whole page, you're officially a newline localizing legend now, go forth and convert 🌈

and that's a wrap babes β€” this was File::...wlines(3pm) from perl v5.36.0, dated 2023-07-01, mwah πŸ’‹ periodt. πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from