GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  SLURP (3)

.ds Aq ’

NAME

Slurp - Slurp entire files into variables

CONTENTS

SYNOPSIS



 use Slurp;

 my $file = slurp($file1, $file2, ...);

 my @array = Slurp::to_array($filename);
 my $scalar = Slurp::to_scalar($filename);



DESCRIPTION

This simple module serves one purpose - to provide a simple means to read (or slurp) an entire file into memory for processing. This module allows the replacement of the prototypical foreach- or while- loops used for opening and reading of files with single-line constructs.

Of note with this module is that the magic of the @ARGV variable and the input record separator, $/, are used to facilitate the reading of entire files into either an array or scalar using minimal code.

METHODS

The following methods are available through this module for use in other applications. By default, the slurp method is exported into the calling namespace - The other methods of this module, to_array and to_scalar, may also be exported into the calling namespace.
<B>slurpB>


 my @array = slurp($filename, ...);
 my $scalar = slurp($filename, ...);



This method slurps one or more files, specified by filenames passed to this method as arguments, into memory. The assignment can be made either either an array or scalar depending upon the context in which this method was called.

<B>to_arrayB>


 my @array = Slurp::to_array($filename, ...);
 my $array_ref = Slurp::to_array($filename, ...);



This method slurps one or more files, specified by filenames passed to this method as arguments, into memory. If called in a scalar context, this method returns an array reference - This is particularly useful if dealing with large files.

<B>to_scalarB>


 my $scalar = Slurp::to_scalar($filename, ...);



This method slurps one or more files, specified by filenames passed to this method as arguments, into a scalar variable.

SEE ALSO

File::Slurp

VERSION

0.4

AUTHOR

Rob Casey
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 SLURP (3) 2003-01-12

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.