Update:Sorry I haven't been more forthcoming on this. I rna into a project that's consumed a lot of my time. My original module looks like this:
package RDW; use strict; use warnings; use Carp; require Exporter; our( $VERSION, @ISA, @EXPORT ); $VERSION = "0.1"; @ISA = qw(Exporter); sub rdw_open { my $self; my $class = shift; my $file = shift; $file =~ s/^/</ if ( $file =~ m!^/?\w! ); open( my $fh, $file, @_ ) or return undef; $self->{FILE} = $fh; #$self->{FILENAME} = $filename; bless $self, $class; return $self; } sub rdw_close { my $self = shift; my $fh = $self->{FILE}; close($fh) or return undef; return 1; } sub read_rdw { my $self = shift; my $fh = $self->{FILE}; my ( $rec_len, $rc, $len, $ret_val ); # Read record length $rc = sysread( $fh, $rec_len, 2 ); ( !defined($rc) ) && die "ERROR: rdw_read() failed read.\n"; $len = unpack( "S", $rec_len ); # Read record data if ( !defined($len) ) { return undef; } $rc = sysread( $fh, $ret_val, $len ); ( !defined($rc) ) && die "ERROR: rdw_read() failed read.\n"; # Return record data return $ret_val; } sub write_rdw { my $self = shift; my $fh = $self->{FILE}; my $line = join "", @_; print( $fh pack( "S", length($line) ), $line ) or croak "Can't write record to file: $!"; }
My attempts at the PerlIO layer thus far are pretty pitiful. I guess I'm not understanding what the purpose of the PUSHED function is vs the OPEN function. From what I can tell, my OPEN will just be a call to my rdw_open. Similarly, FILL is just a wrapper around read_rdw and WRITE around write_rdw. I can't for the life of me figure out what PUSHED is supposed to do, however.

Also, feel free to comment on the original module. Perhaps there's some modifications that could be made there that would make the work here easier.

thor

Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come


In reply to Re: Making my own PerlIO layer by thor
in thread Making my own PerlIO layer by thor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.