File::Read(3pm) | User Contributed Perl Documentation | File::Read(3pm) |
File::Read - Unique interface for reading one or more files
Version 0.0801
use File::Read; # read a file $file = read_file($path); # read several files @files = read_files(@paths); # aggregate several files $file = read_files(@paths); # read a file as root, skip comments and blank lines $file = read_file({ as_root => 1, skip_comments => 1, skip_blanks => 1 }, $path);
This module mainly proposes functions for reading one or more files, with different options. See below for more details and examples.
This module was created to address a quite specific need: reading many files, some as a normal user and others as root, and eventually do a little more processing, all while being at the same time compatible with Perl 5.004. "File::Slurp" addresses the first point, but not the others, hence the creation of "File::Read". If you don't need reading files as root or the post-processing features, then it's faster to directly use "File::Slurp".
By default, this module exports all the functions documented afterhand. It also recognizes import options. For example
use File::Read 'err_mode=quiet';
set "read_file()"'s "err_mode" option default value to "quiet".
Options
Examples
Just read a file:
my $file = read_file($path);
Read a file, returning it as list:
my @file = read_file({ aggregate => 0 }, $path);
Read a file, skipping comments:
my $file = read_file({ skip_comments => 1 }, $path);
Read several files, skipping blank lines and comments:
my @files = read_file({ skip_comments => 1, skip_blanks => 1 }, @paths);
File::Slurp
IO::All
Sebastien Aperghis-Tramoni, "<sebastien at aperghis.net>"
Please report any bugs or feature requests to "bug-file-read at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Read>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc File::Read
You can also look for information at:
Copyright (C) 2006, 2007 Sebastien Aperghis-Tramoni, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2022-11-27 | perl v5.36.0 |