I am requesting comments on namespace for the following package which I would like to upload to CPAN.

    package Yet::To::Be::Named;
    use strict;
    use Carp;

    sub TIEHANDLE {
        my $class = shift;
        my @lines = @_;
        bless [EMAIL PROTECTED], $class;
    }

    sub READLINE {
        my $self = shift;
        if (@$self) {
            shift @$self;
        } else {
            croak "List of prompt responses has been exhausted: $!";
        }
    }

    1;

This is a simple implementation of a tied filehandle not unlike TieIn and TieOut which are now included in Perl 5.8.6 (http://search.cpan.org/src/NWCLARK/perl-5.8.6/t/lib/TieIn.pm, http://search.cpan.org/src/NWCLARK/perl-5.8.6/t/lib/TieOut.pm). Tied filehandles are discussed in 'perldoc perltie' and in Chapter 14 of Programming Perl, 3rd ed.

I use this code in a testing context to test modules that in production use require an operator response via STDIN. The test script supplies an array of values which are supplied to testing subroutines at moments which appropriately pre-empt standard input.

Hence, my local name for this package is 'Preempt::Stdin', and I discussed it under that name in a thread on Perlmonks two months ago (http://www.perlmonks.org/index.pl?node_id=430997). That name accurately describes *how I use* the code, but the code does not (at least on its face) require that STDIN be the filehandle that is tied, nor is preemption in a testing context (or 'overloading', as some might prefer) the only conceivable use of the code.

Since the code works for me I'd like to document it and write tests for it so that I can share it with others via CPAN. But I suspect it could use a name that is not so tightly bound to my own particular use of it.

How does Tie::Filehandle::Input sound?

Jim Keenan

Reply via email to