IO::Lines - IO:: interface for reading/writing an array of lines
| Use Case | Command | Description |
|---|---|---|
| Create an IO::Lines object from an array | IO::Lines->new(\@array) | Opens the array for reading/writing lines |
| Create for writing to a new array | IO::Lines->new() | Creates an empty array; lines can be appended |
| Tie a handle to an array of lines | tie *HANDLE, 'IO::Lines', \@array | Makes HANDLE behave like a filehandle on the array |
| Read a line | $line = or $io->getline() | Returns next line (with "\n" except possibly last) |
| Print lines | print $io @lines | Auto-breaks data at newlines; each element ends with "\n" |
use IO::Lines;
### See IO::ScalarArray for details
This class implements objects which behave just like FileHandle (or IO::Handle) objects, except that you may use them to write to (or read from) an array of lines. They can be tiehandle'd as well.
This is a subclass of IO::ScalarArray in which the underlying array has its data stored in a line-oriented-format: that is, every element ends in a "\n", with the possible exception of the final element. This makes getline() much more efficient; if you plan to do line-oriented reading/printing, you want this class.
The print() method will enforce this rule, so you can print arbitrary data to the line-array: it will break the data at newlines appropriately.
See IO::ScalarArray for full usage and warnings.
$Id: Lines.pm,v 1.3 2005/02/10 21:21:53 dfs Exp $
Dianne Skoll (dfs AT roaringpenguin.com).
Eryq (eryq AT zeegee.com). President, ZeeGee Software Inc (http://www.zeegee.com).
getlines().Generated by phpman v4.9.29 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-22 00:26 @2600:1f28:365:80b0:d8a5:c3c6:bf94:28c0
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format