#strictStudy.pl
use strict 'refs';
$ref = \$foo;
print $$ref;
$ref = "foo";
#print $$ref;
#note:symbolic reference forbidden.
$file = "STDOUT";
$file2 = "STDIN";
print $file," Hi!";
#note:function case is exception case.
$bar = \&{'foo'}; #$bar get ref to function foo
&$bar;#Use &$bar to invoke the referenced function.
sub foo{
print "foo function invoked..\n";
}
sub bar{
print "bar function invoked...\n";
}
#輸出結果:
STDOUT Hi!foo function invoked..
沒有留言:
張貼留言