package MY_TEST;
use warnings;
use strict;
use Win32::Console;
my $out = Win32::Console->new( STD_OUTPUT_HANDLE );
sub test_print {
$out->Write( "printed with 'Write'\n" );
print( "printed with 'print'\n" );
}
当我用这个脚本调用这个包时
#!/usr/bin/env perl
use warnings;
use strict;
use 5.10.0;
use FindBin qw($RealBin);
use MY_TEST;
say 'Before "test_print"';
MY_TEST::test_print;
say 'After "test_print"';
输出看起来像这样
Before "test_print"
printed with 'Write'
printed with 'print'
After "test_print"
但是当我评论这Write
条线时
# $out->Write( "printed with 'Write'\n" );
输出为空。
为什么删除Write
线会阻止打印print
线?