Simple question:
I want to write a function like say.
But it had one bad feature: a filehandle.
say FILEHANDLE LIST
say FILEHANDLE
say LIST
say
How to declare it? Is it possible?
P.S:
I find an example with myopen(*;$), but it’s not the same thing.
P.P.S:
I need this function in old Perl versions, because it is annoying to write print "\n"
Thanks!
Perl6::Say does just that.
It cleverly emulates the
say FILEHANDLE TEXTsyntax by taking advantage of Perl’s usually very annoying indirect method call syntax. It loads IO::Handle turning every filehandle into an object and createsIO::Handle->say. Nowsay FILEHANDLE TEXTis actuallyFILEHANDLE->say(TEXT).It does have caveats. From the docs…
UPDATE: To make this even simpler, I have just uploaded Say::Compat which loads either Perl6::Say or
use feature 'say'depending on your version of Perl.That’s the best you’re likely to get without playing with Devel::Declare.