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

Discussion in 'Perl Misc' started by kj, Oct 16, 2008.

  1. kj

    kj Guest

    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
    --
    NOTE: In my address everything before the first period is backwards;
    and the last period, and everything after it, should be discarded.
    kj, Oct 16, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gordon

    perlio problem? redhat 9, perl 5.8.0

    gordon, Jun 24, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    123
    gordon
    Jun 27, 2003
  2. Dave
    Replies:
    0
    Views:
    134
  3. Bo Lindbergh

    PerlIO omission

    Bo Lindbergh, Jun 8, 2006, in forum: Perl Misc
    Replies:
    6
    Views:
    112
    Charles DeRykus
    Jun 8, 2006
  4. Mark Seger

    I think I want to use of mmap and perlio

    Mark Seger, Jun 15, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    147
    Tim S
    Jun 15, 2007
  5. Replies:
    2
    Views:
    141
Loading...

Share This Page