http://qs321.pair.com?node_id=11124012


in reply to Re^2: What's the right way to write a method which returns one line at a time from a file?
in thread What's the right way to write a method which returns one line at a time from a file?

$self->{file_handle} = $self->get_filehandle( $self->{file} );

You can't reload or open a new file using the above. Additionally, you can end up having a discrepancy whereas $self->{file} points to one file and $self->{file_handle} to another. If you want that functionality, then I would set file_handle inside get_filehandle() with appropriate logic.

  • Comment on Re^3: What's the right way to write a method which returns one line at a time from a file?
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: What's the right way to write a method which returns one line at a time from a file?
by Cody Fendant (Hermit) on Nov 28, 2020 at 03:18 UTC

    I always run this code on one unique file name at a time, but thanks for the contribution, I appreciate it.