Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by bliako (Prior)
on Nov 22, 2020 at 09:48 UTC ( #11124012=note: print w/replies, xml ) Need Help??


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 (Friar) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11124012]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2021-03-03 22:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (96 votes). Check out past polls.

    Notices?