[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: [5.1.4] "attempt to index global 'data' (a nil value)
- From: Dave Collins <Dave.Collins@...>
- Date: Tue, 26 Jul 2011 15:59:41 -0400
> I'm pretty new but it looks like no one's responded.
Sorry, I see the other responses now. This got trapped as spam so it stuck out as a singleton post.
(Trying to contribute back the the community that's been so much help)
Dave Collins
-----Original Message-----
From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Gilles Ganault
Sent: Sunday, July 24, 2011 8:56 AM
To: lua-l@lists.lua.org
Subject: [5.1.4] "attempt to index global 'data' (a nil value)
Hello
Using a Lua script on XP, I need to open an HTML file and extract
hyperlinks...
===========
data = io.open("C:\places.txt","r")
for line in data:lines() do
for token in string.gmatch(line, '<a
href="(/places/.+?\.php)">') do
print(token)
end
end
data:close()
===========
... but it fails with the following error message:
===========
lua5.1.exe: places.lua:2: attempt to index global 'data' (a nil value)
===========
Any idea what is wrong with the above?
Thank you.