Get a certain line in file

Compaq ?
November 27, 2009 at 22:40:26
Specs: Windows 98, ?
Hi, i've got an .html page that contains some perlscript in it.
<script type="text/perlscript">
open(FILE, "/file.txt");
# This is where I want to take line 3 of "file.txt" and 
# turn it into the string "$linethree". 
print "$linethree";

How do I retrieve line 3 of file.txt and turn it into a string in text/perlscript? I know it's possible, but I just don't know how to do it. Thanks in advance.

~DOS programmeR
"Computers are fickle. They do only that of which they feel. Otherwise, they just don't work."

See More: Get a certain line in file

Report •

November 28, 2009 at 00:30:07
With perl, you can read a whole file into an array by using something like

open(FILE, "<filename");
my @fdata = <FILE>;

print $fdata[2]; // line 3 of file

Whether or that would work with this scripting method, I couldn't say as I've never used it. After reading up on it a bit, it doesn't seem very practical for use with publicly accessed pages. If that's your goal, then it would *probably* be better to use server side scripting along with ajax or something.


Report •

December 4, 2009 at 15:34:37
thanks. I'll try that.

Report •

Related Solutions

Ask Question