File::Slurp

File::Slurp is a Perl module for efficient reading/writing of Complete files.
Download

File::Slurp Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Uri Guttman
  • Publisher web site:
  • http://search.cpan.org/~uri/Sort-Maker-0.06/Sort/Maker.pm

File::Slurp Tags


File::Slurp Description

File::Slurp is a Perl module for efficient reading/writing of Complete files. File::Slurp is a Perl module for efficient reading/writing of complete files.SYNOPSIS use File::Slurp; my $text = read_file( 'filename' ) ; my @lines = read_file( 'filename' ) ; write_file( 'filename', @lines ) ; use File::Slurp qw( slurp ) ; my $text = slurp( 'filename' ) ;This module provides subs that allow you to read or write entire files with one simple call. They are designed to be simple to use, have flexible ways to pass in or get the file contents and to be very efficient. There is also a sub to read in all the files in a directory other than . and ..These slurp/spew subs work for files, pipes and sockets, and stdio, pseudo-files, and DATA.read_fileThis sub reads in an entire file and returns its contents to the caller. In list context it will return a list of lines (using the current value of $/ as the separator including support for paragraph mode when it is set to ''). In scalar context it returns the entire file as a single scalar. my $text = read_file( 'filename' ) ; my @lines = read_file( 'filename' ) ;The first argument to read_file is the filename and the rest of the arguments are key/value pairs which are optional and which modify the behavior of the call. Other than binmode the options all control how the slurped file is returned to the caller.If the first argument is a file handle reference or I/O object (if ref is true), then that handle is slurped in. This mode is supported so you slurp handles such as DATA, STDIN. See the test handle.t for an example that does open( '-|' ) and child process spews data to the parant which slurps it in. All of the options that control how the data is returned to the caller still work in this case.NOTE: as of version 9999.06, read_file works correctly on the DATA handle. It used to need a sysseek workaround but that is now handled when needed by the module itself.You can optionally request that slurp() is exported to your code. This is an alias for read_file and is meant to be forward compatible with Perl 6 (which will have slurp() built-in). Requirements: · Perl


File::Slurp Related Software