perl-like "slurp" in PHP?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
There is a module for perl called "slurp" which (from the documentation)
'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.'

In its simplest use, it can read a file (everything in unix is a "file"
of strings, webpages, socket output, everything) into an array, one line
at a time into one array element.

I often use it to suck an entire webpage into an array and iterate
through the contents while in memory. I've seen routines to suck a file
into a string, so something similar will probably work for an array but
does anyone know if there's a function or class for PHP that already
does this?

Re: perl-like "slurp" in PHP?

Do you mean like this?

- Kevin

Quoted text here. Click to load it

Re: perl-like "slurp" in PHP?

Quoted text here. Click to load it
thats it; thanks.

some functions have the similar names (eg. unlink) and some don't. (I
would have thought 'file' might be a reserved word.)

Site Timeline