use strict;
use diagnostics;
sub myprint {
my( $fh, $text ) = @_;
print $fh $text;
}
myprint( STDOUT, "Hello world!\n" );
####
Bareword "STDOUT" not allowed while "strict subs" in use at mytest.pl line 15.
Execution of mytest.pl aborted due to compilation errors (#1)
(F) With "strict subs" in use, a bareword is only allowed as a
subroutine identifier, in curly brackets or to the left of the "=>"
symbol. Perhaps you need to predeclare a subroutine?
Uncaught exception from user code:
Bareword "STDOUT" not allowed while "strict subs" in use at mytest.pl line 15.
Execution of mytest.pl aborted due to compilation errors.
####
use strict;
use diagnostics;
sub myprint {
my( $fh, $text ) = @_;
print $fh $text;
}
sub STDOUT {
print "Woops!\n";
}
myprint( STDOUT, "Hello world!\n" );
####
Woops!
Can't use string ("1") as a symbol ref while "strict refs" in use at mytest.pl
line 8 (#1)
(F) You've told Perl to dereference a string, something which
use strict blocks to prevent it happening accidentally. See
"Symbolic references" in perlref. This can be triggered by an @ or $
in a double-quoted string immediately before interpolating a variable,
for example in "user @$twitter_id", which says to treat the contents
of $twitter_id as an array reference; use a \ to have a literal @
symbol followed by the contents of $twitter_id: "user \@$twitter_id".
Uncaught exception from user code:
Can't use string ("1") as a symbol ref while "strict refs" in use at mytest.pl line 8.
main::myprint(1, 'Hello world!\x{a}') called at mytest.pl line 15
####
use strict;
use diagnostics;
sub myprint {
my( $fh, $text ) = @_;
print $fh $text;
}
sub STDOUT {
print "Woops!\n";
}
myprint( \*STDOUT, "Hello world!\n" );