"Out of memory!" error with PerlIO::via

K

kj

I've written a very simple PerlIO::via module, that implements only
two API functions:

sub PUSHED { bless \*PUSHED, $_[ 0 ] } # lifted from PerlIO::via::QuotedPrint
sub FILL {
my $in = $_[ 1 ];
while ( <$in> ) {
next if _is_blank_or_comment( $_ );
my ( $q, $e ) = ( split /\t/, $_, -1 )[ 3, 6 ];
return $_ unless length $q or $e !~ /$SOME_REGEXP/;
}
return undef;
}

When I use this layer like this:

open my $in, '<:via(MyLayer)', '/path/to/some/file' or die $!;
while ( <$in> ) { print }

....I get an "Out of memory!" error.

Intriguingly enough, if I run the same code through the Perl
debugger, it produces the correct output and the program terminates
without an error.

This behavior under the debugger is good news and bad news. The
good news is that it suggests that, whatever the problem is, it is
not something like a syntax error or some other error of usage
(e.g. wrong order of arguments to some function, etc.) in my code.

The bad news I can't use the debugger to get to the bottom of this!

In fact I've run out of ways to troubleshoot this problem.

Any ideas? (I'm open to the possibility of using something other
than PerlIO layers to implement this general filtering function.)

TIA!

Kynn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top