Anonymous user
Read a specific line from a file: Difference between revisions
Read a specific line from a file (view source)
Revision as of 02:35, 28 September 2011
, 12 years ago→From the bottom: Wrong: skip must be bounded.
(→{{header|TXR}}: Can do from the bottom, too, in bleeding edge code.) |
(→From the bottom: Wrong: skip must be bounded.) |
||
Line 314:
<lang txr>@(skip)
@line
@(skip
@(eof)</lang>
How this works is that the first <code>skip</code> will skip enough lines until the rest of the query successfully matches the input. The rest of the query matches a line, then skips two lines, and matches on EOF. So <code>@line</code> can only match at one location: three lines up from the end of the file. If the file doesn't have at least three lines, the query fails.
|