in reply to Almost certainly a module documentation issue

A preliminary attempt to look at the source code of the module foundered

It's here, the bit of code that is relevant here is "has 'fh' => ( isa => InstanceOf['IO::Handle'], ..." (and yes, this is from Moo).

To put 1nickt's suggestion into code - if you modify your code like the following, it works for me:

use IO::Handle; my $sm = IO::Handle->new; open ($sm, ...

Replies are listed 'Best First'.
Re^2: Almost certainly a module documentation issue
by dd-b (Pilgrim) on Oct 14, 2017 at 20:24 UTC

    This worked. This code ran, and the result was acceptable to Email::Sender::Transport::Print->new().

    In some ways I'm more confused than ever, though, because when I display the filehandle in perldb the new code shows me

    DB<4> x $sm 0 IO::Handle=GLOB(0x80695a1c8) -> *Symbol::GEN0 FileHandle({*Symbol::GEN0}) => fileno(7) DB<5> n

    while isn't IO::Handle anywhere, and duplicates the FileHandle shown in the original code (but wrapped a level down). Still, it's clearly different, and it works, so I won't complain :-).

      while isn't IO::Handle anywhere, and duplicates the FileHandle shown in the original code

      It's an object of type IO::Handle, as shown in the first line of the dump. Basically IO::Handle->new boils down to blessing a new symbol as returned by Symbol::gensym (which explains the second line of the dump) into the class IO::Handle (source). If you step through the code, you should see the following:

      **Before** the open() 0 IO::Handle=GLOB(0x1948fb2) -> *Symbol::GEN0 **After** the open() 0 IO::Handle=GLOB(0x1948fb2) -> *Symbol::GEN0 FileHandle({*Symbol::GEN0}) => fileno(7)

      So the FileHandle appears to be the result of opening the file.