NAME

    File::Edit::Portable - Read and write files while keeping the original
    line-endings intact, no matter the platform.

SYNOPSIS

        use File::Edit::Portable;
    
        my $rw = File::Edit::Portable->new;
    
        my @contents = $rw->read(file => 'file.txt');
    
        push @contents, 'line 1', 'line 2';
    
        $rw->write(file => 'file.txt', contents => \@contents);
    
        $hex_record_separator = $rw->recsep('file');

DESCRIPTION

    This module will read in a file, and keep track of the file's current
    line endings, and write the file back out using those same original
    line endings.

    Uses are for dynamically reading/writing files while on one Operating
    System, but you don't know that the record separator (line endings) are
    platform-standard.

    You're returned an array with all of the lines of the file on read. You
    can then manipulate it, and then pass it back for re-writing the file
    (or a copy).

METHODS

 new

    Returns a new File::Edit::Portable object.

 read

    Opens a file and extracts its contents, returning an array of the files
    contents where each line of the file is a separate element in the
    array.

    Parameters: file => 'filename'

 write

    Writes the data back to the original file, or alternately a copy of the
    file. Returns 1 on success.

    Parameters:

    file => 'file': Not needed if you've used read() to open the file.

    copy => 'file2': Set this if you want to write to an alternate file,
    rather than the original.

    contents => \@contents: Mandatory, should contain a reference to the
    array that was returned by read().

 recsep('file')

    Returns a string of the hex representation of the line endings (record
    separators) in 'file'. For example, "\0d\0a" will be returned for
    Windows line endings (CRLF).

AUTHOR

    Steve Bertrand, <steveb at cpan.org>

BUGS

    Please report any bugs or feature requests to bug-file-edit-portable at
    rt.cpan.org, or through the web interface at
    http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Edit-Portable. I
    will be notified, and then you'll automatically be notified of progress
    on your bug as I make changes.

SUPPORT

    You can find documentation for this module with the perldoc command.

        perldoc File::Edit::Portable

    You can also look for information at:

      * RT: CPAN's request tracker (report bugs here)

      http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Edit-Portable

      * Search CPAN

      http://search.cpan.org/dist/File-Edit-Portable/

LICENSE AND COPYRIGHT

    Copyright 2015 Steve Bertrand.

    This program is free software; you can redistribute it and/or modify it
    under the terms of either: the GNU General Public License as published
    by the Free Software Foundation; or the Artistic License.

    See http://dev.perl.org/licenses/ for more information.

