in reply to Is there a way to emulate 'print' using prototype?

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.)

Replies are listed 'Best First'.
Re^2: Is there a way to emulate 'print' using prototype?
by AGhoulDoingPerl (Sexton) on May 18, 2011 at 20:45 UTC
    Thank ikegami for your answer. So there is no direct way to do so:(