tobold.org

correct • elegant • free

△ comp.lang.perl △

◅ How do I retrieve all the items that occur in one list but not in another ?

How do I pass in arrays to subroutines ? ▻

@ISA = qw(FileHandle); can this work?

I have a module which defines a class derived from FileHandle (it's
for manipulating Unix style `From ' delimited mailboxes).

The module boilerplate includes this...

    package Mail::Mbox;
    @ISA = qw(FileHandle);

Code that uses the module can, apparently happily, mix inherited
methods, such as `new' and `tell', with the methods defined in
Mail/Mbox.pm, such as `next' in this example.

    $mboxin = new Mail::Mbox ($mbfile, "<") or die ...
    while ($curpos = $mboxin->tell, $msgref = $mboxin->next) {
            ...

The module has seen heavy use under 5.001m and 5.002, and it seems
solid.  However, I have just discovered this text in the FileHandle
documentation.

    BUGS
         Due to backwards compatibility, all filehandles resemble
         objects of class FileHandle, or actually classes derived
         from that class.  They actually aren't.  Which means you
         can't derive your own class from FileHandle and inherit
         those methods.

This appears to say that Mail::Mbox "shouldn't" work (although the prose
is a little bit unclear: what is the referent of "those methods"?).

Do I need to rethink Mail::Mbox?  What, if any, is the correct way to
define a class that looks like FileHandle?

Tim.
--
Tim Goodwin   | "continuous witter about large metal wanking
Cambridge, UK | machines" -- Robin Fairbairns, about uk.transport.

Original headers:

From: tim@pipex.net (Tim Goodwin)
Newsgroups: comp.lang.perl.misc
Subject: @ISA = qw(FileHandle); can this work?
Date: 16 Apr 1996 10:44:41 GMT
Organization: Unipalm PIPEX
Message-ID: <4kvtmp$5mg@wave.news.pipex.net>

△ comp.lang.perl △

◅ How do I retrieve all the items that occur in one list but not in another ?

How do I pass in arrays to subroutines ? ▻