IO::Easy::File - IO::Easy child class for operations with files.
my $io = IO::Easy->new ('.'); my $file = $io->append('example.txt')->as_file; print $file->contents; # prints file content print $file->path; # prints file path, in this example it's './example.txt'
IO::Easy::File has 2 methods for saving file: store and store_if_empty
my $io = IO::Easy->new ('.'); my $file = $io->append('example.txt')->as_file; my $content = "Some text goes here"; $file->store($content); # saves the variable $content to file $file->store_if_empty ($content); # saves the variable $content to file, only # if there's no such a file existing.
read strings from file in normal or reverse order
$io->string_reader (sub { my $s = shift; print $s; });
read from file end
$io->string_reader (sub { my $s = shift; print $s; }, reverse => 1);
parse __DATA__ section and return hash of file contents encoded as:
__DATA__ ######################## # IO::Easy file1 ######################## FILE1 CONTENTS ######################## # IO::Easy file2 ######################## FILE2 CONTENTS
returns
{ file1 => 'FILE1 CONTENTS', file2 => 'FILE2 CONTENTS', }
file encoding for reading and writing files. by default '', which is :raw for PerlIO. you can redefine it by providing supported encoding, as example utf-8 or ascii
PerlIO layer name for reading and writing files. you can redefine it by providing argument
chunk size for file reading, storing and moving
moving file to another path
always 'file'
similar to unix touch command - updates file timestamp
Ivan Baktsheev, <apla at the-singlers.us>
<apla at the-singlers.us>
Please report any bugs or feature requests to my email address, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IO-Easy. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
Copyright 2007-2009 Ivan Baktsheev
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install IO::Easy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Easy
CPAN shell
perl -MCPAN -e shell install IO::Easy
For more information on module installation, please visit the detailed CPAN module installation guide.