[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string io?
- From: Petite Abeille <petite.abeille@...>
- Date: Thu, 12 Apr 2012 20:10:22 +0200
On Apr 12, 2012, at 7:43 PM, Michal Kottman wrote:
> Do you mean the Penlight pl.stringio module?
> http://stevedonovan.github.com/Penlight/api/modules/pl.stringio.html
Hmmm… yes… possibly… at first glance Penlight doesn't support the 5.2 IO API (e.g. io:lines( '*L' ) )… I kind of recall something that did… perhaps the figment of my imagination though :)
P.S.
As an aside, Penlight's io:lines() method seems to silently drop the last empty line.
local stringio = require 'pl.stringio'
local aString =
[[
foo
bar
baz
]]
local aCount = 0
for aLine in stringio.open( aString ):lines() do
aCount = aCount + 1
print( aCount, aLine )
end
> 1
> 2 foo
> 3
> 4 bar
> 5
> 6 baz
There should be 7 lines altogether.