in reply to Re^2: file handle var for print command
in thread file handle var for print command

Filehandle GLOBs behave like IO::Handle instances (but aren't actually for purposes of inheritance according to the BUGS entry in the IO::Handle docs) so that's just a normal method call to the print method and doesn't get into weird indirect object parsing corners.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^4: file handle var for print command
by ikegami (Patriarch) on Sep 24, 2025 at 15:01 UTC

    Not quite.

    They behave like IO::File objects (since 5.12).

    $ perl -e'STDOUT->foo' Can't locate object method "foo" via package "IO::File" at -e line 1.

    They do obey inheritance.

    $ perl -e'use IO::File; IO::File::say( *STDOUT, "ok" )' Undefined subroutine &IO::File::say called at -e line 1. $ perl -e'use IO::File; IO::Handle::say( *STDOUT, "ok" )' ok $ perl -e'STDOUT->say( "ok" )' ok

    (IO::Handle's docs is merely saying IO::File isn't a derivable class since My::IO::File->new will create an IO::File "object" instead of a My::IO::File object.)

    And the issue raised wasn't why it works; it was about where it's documented. I could not find it either.