use strict;
use warnings;
use feature qw/ say /;
use Scalar::Util qw/ blessed /;
open my $fh, "+>", undef;
say $fh-> can( "print" ) ? "yes" : "no"; # no
print $fh 123;
say $fh-> can( "print" ) ? "yes" : "no"; # no
$fh-> print( 123 );
say $fh-> can( "print" ) ? "yes" : "no"; # yes
say "no" unless blessed $fh; # no
####
use strict;
use warnings;
use feature qw/ say /;
open my $fh, "+>", undef;
say $fh-> can( "print" ) ? "yes" : "no"; # no
autoflush $fh 1;
say $fh-> can( "print" ) ? "yes" : "no"; # yes
####
$ perl -MO=Deparse -e '
> open my $fh, "+>", undef;
> autoflush $fh 1;
> $fh-> autoflush( 1 );
> print $fh 123;
> $fh-> print( 123 );
> '
open my $fh, '+>', undef;
$fh->autoflush(1);
$fh->autoflush(1);
print $fh 123;
$fh->print(123);
-e syntax OK
####
use strict;
use warnings;
use feature qw/ say /;
{
open my $fh, "+>", undef;
say $fh-> can( "print" ) ? "yes" : "no"; # no
autoflush $fh 1;
say $fh-> can( "print" ) ? "yes" : "no"; # yes
}
package different;
{
open my $foo, "+>", undef;
open my $bar, "+>", undef;
say $foo-> can( "print" ) ? "yes" : "no"; # yes
say $bar-> can( "print" ) ? "yes" : "no"; # yes
}
####
use strict;
use warnings;
use Log::Log4perl qw / :easy /;
use Log::Dispatch::Handle;
open my $fh, "+>", undef;
my $app = Log::Log4perl::Appender-> new(
"Log::Dispatch::Handle",
min_level => "debug",
newline => 0,
handle => $fh );
__END__
GLOB(0x1ea3a0) is missing the 'print' method
####
Use of uninitialized value $list in concatenation (.) or string at C:/berrybrew/5.26.0_64_PDL/perl/vendor/lib/Specio/Constraint/Role/CanType.pm line 58.
GLOB(0x2d6a3a0) is missing the methods
####
An unblessed reference (GLOB(0x560dc7cc1348)) will never pass an AnyCan check (wants print)
####
my $fh = IO::File-> new( 'some.log', 'w' );