aboutsummaryrefslogtreecommitdiff
path: root/challenge-072/stuart-little/lua/ch-2.lua
diff options
context:
space:
mode:
authorchirvasitua <chirvasitua@gmail.com>2021-07-16 17:52:36 -0400
committerchirvasitua <chirvasitua@gmail.com>2021-07-16 17:52:36 -0400
commita66637f07937337ae048b18a4c8beadf4a82e887 (patch)
treedb08427e6c7bfb0083ef0e881a9f40679a4024fd /challenge-072/stuart-little/lua/ch-2.lua
parent1eec60b6cab6562a5eef76a369c0abe704d45f82 (diff)
downloadperlweeklychallenge-club-a66637f07937337ae048b18a4c8beadf4a82e887.tar.gz
perlweeklychallenge-club-a66637f07937337ae048b18a4c8beadf4a82e887.tar.bz2
perlweeklychallenge-club-a66637f07937337ae048b18a4c8beadf4a82e887.zip
1st commit on 072_lua
Diffstat (limited to 'challenge-072/stuart-little/lua/ch-2.lua')
-rwxr-xr-xchallenge-072/stuart-little/lua/ch-2.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-072/stuart-little/lua/ch-2.lua b/challenge-072/stuart-little/lua/ch-2.lua
new file mode 100755
index 0000000000..9c7d4bb302
--- /dev/null
+++ b/challenge-072/stuart-little/lua/ch-2.lua
@@ -0,0 +1,16 @@
+#!/usr/bin/env lua
+
+-- run <script> <file 1st-line-nr 2nd-line-nr>
+
+function lnRng(pth,l1,l2)
+ local ix,lns=0,{}
+ for l in io.lines(pth) do
+ ix=ix+1
+ if ix>=l1 and ix<=l2 then table.insert(lns,l) end
+ end
+ return lns
+end
+
+for _,l in ipairs(lnRng(arg[1],tonumber(arg[2]),tonumber(arg[3]))) do
+ print(l)
+end