while(my $line = $reader->get_next_line()){
I just wanted to point out that this suffers from the same issue that AnomalousMonk correctly pointed out deeper in the thread: if the file ends on a line containing just "0" with no newline, this loop won't catch that. You would have to say while( defined( my $line = $reader->get_next_line() ) ) instead. Alternatively, note it's possible to overload the <> operator (note that overloaded <> in list context wasn't implemented until 5.18). See for example my use in Algorithm::Odometer::Tiny; you'd just have to change $self->() to your method call, and then you could write while( my $line = <$reader> ) and Perl will automatically add the defined call.
By the way, in your post here, I don't understand the point of the two $self->{file} = shift; lines, especially the second one? Why change the filename while reading the file?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|