Fellows monks,
I ask the enlightment of your wisdom about the following little problem.
As stated in perlfunc, readline(*HANDLE) returns undef at the end of file. The same obviously is true for the IO::File getline method.
I'm writing a class inheriting from IO::File which should read records from a formatted file. Obviously, the main thing to do, maybe the only one, is to redefine getline method.
My getline method looks like this:
sub getline { my $self = shift; my $line = $self->SUPER::getline() || return undef; #the _parse function check if the line is well formed and #returns a hash references filled with informations from #the line. _parse() returns undef if there is a format #error in the line my $result = _parse($line); if (defined $result) { return $result; } else { #this is the tricky part... #what should I do? } }
The problem is that I'm unable to decide what should my method do when the file is not actually at EOF but the current line is malformed. The options appears to be 'the same thing' as IO::File->getline(), but I can not found what this 'thing' is by reading the doc, or die-ing, which would oblige me to always wrap the calls to the method into a eval block.
What I'm asking from your wisdom is then:
Thanks for helping.
update: corrected some typos
In reply to readline error behavior by TheHobbit
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |