Indirect method calls gets you pretty close:
$ perl -E' sub IO::Handle::myprint { say "..."; } sub myprint { myprint STDOUT @_ } myprint STDOUT "foo"; myprint "foo"; eval q{ myprint(STDOUT "foo"); 1 } or warn $@; eval q{ myprint(\*STDOUT "foo"); 1 } or warn $@; eval q{ myprint { STDOUT } "foo"; 1 } or warn $@; eval q{ myprint { \*STDOUT } "foo"; 1 } or warn $@; ' syntax error at (eval 1) line 1, near "STDOUT "foo"" syntax error at (eval 2) line 1, near "*STDOUT "foo"" syntax error at (eval 3) line 1, near "} "foo"" syntax error at (eval 4) line 1, near "} "foo""
(Some bits omitted from the error messages for readability.)
In reply to Re: Is there a way to emulate 'print' using prototype?
by ikegami
in thread Is there a way to emulate 'print' using prototype?
by AGhoulDoingPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |