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->pread(file => 'file.txt');
    
        push @contents, 'line 1', 'line 2';
    
        $rw->pwrite(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 what 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 them manipulate it, and then pass it back for re-writing the file
    (or a copy).

METHODS

 new

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

 pread

    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'

 pwrite

    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 pread() 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 pread().

 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-rw-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.

