Trina Espinoza wrote:
>
> So this may be wishful thinking, but I would be kicking myself later if I didn't
> ask. Is there a function in perl where you give the function  exact line numbers
> and it would only read the data in the range of lines you gave it? My other
> alternative would be using a counter to find a start line and an end line in a
> file. Doable but painful. Let me know if there is any hope . . .

Hi Trina.

Perl and its modules will do most things for you! Try

  use Tie::File;

  tie @myfile, 'Tie::File', 'myfile' or die $!;

then anything in the file will be reflected by the array, like

  print $myfile[$_], "\n" foreach 1, 3, 7;

But remember two things:

- By default, the array elements will /not/ have the newline "\n" record
  terminating string.

- The file is opened read/write by default so modifying the array in any
  way will change the file.

Both of these behaviours can be changed. Look at

  perldoc Tie::File

for how, if you need to know.


HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to