SYNOPSIS

    # Perl 5 code...

use Perl6::Say;

say 'boo'; # same as: print 'boo', "\n"

say STDERR 'boo'; # same as: print STDERR 'boo', "\n"

STDERR->say('boo'); # same as: print STDERR 'boo', \n"

$fh->say('boo'); # same as: print $fh 'boo', "\n";

say(); # same as: print "$_\n";

say undef; # same as: print "\n";

DESCRIPTION

\$1

You don't need this module. The Perl 6 \*(C`say\*(C' function is available in Perl 5.10 by saying \*(C`use feature 'say';\*(C'. Hence, this module is of interest only to users of Perl 5.6 and 5.8.

If you have Perl 5.10 installed, see the 510/ directory in this distribution for some elementary examples of \*(C`say\*(C' taken from \*(C`perldoc feature\*(C'. Implements a close simulation of the \*(C`say\*(C' function in Perl 6, which acts like \*(C`print\*(C' but automatically appends a newline.

Use it just like \*(C`print\*(C' (except that it only supports the indirect object syntax when the stream is a bareword). That is, assuming the relevant filehandles are open for output, you can use any of these:

say @data; say FH @data; FH->say(@data); *FH->say(@data); (\*FH)->say(@data); say $fh, @data; $fh->say(@data);

but not any of these:

say {FH} @data; say {*FH} @data; say {\*FH} @data; say $fh @data; say {$fh} @data; As demonstrated in the test suite accompanying this distribution, \*(C`Perl6::Say::say()\*(C' can be used in all the following situations.

$string = q{}; open FH, ">", \$string; say FH qq{Hello World}; # print to a string close FH; # requires Perl 5.8.0 or later

use FileHandle; $fh = FileHandle->new($file, 'w'); if (defined $fh) { say $fh, qq{Hello World}; $fh->close; }

use IO::File; $fh = IO::File->new($file, 'w'); if (defined $fh) { say $fh, qq{Hello World}; $fh->close; }

$string = q{}; open FH, ">", \$string; # requires Perl 5.8.0 or later select(FH); say qq{Hello World}; close FH; In Perl 6, \*(C`say @stuff\*(C' is exactly equivalent to \*(C`Core::print @stuff, "\n"\*(C'.

That means that a call to \*(C`say\*(C' appends any output record separator (\s-1ORS\s0) after the added newline (though in Perl 6, the \s-1ORS\s0 is an attribute of the filehandle being used, rather than a global $/ variable). IO::Handle version 1.27 or later (which, confusingly, is found in \s-1IO\s0 distribution 1.23 and later) also implements a \*(C`say\*(C' method. Perl6::Say provides its own \*(C`say\*(C' method to IO::Handle if \*(C`IO::Handle::say\*(C' is not available. As noted above, some aspects of \*(C`Perl6::Say::say()\*(C' will not work with versions of Perl earlier than 5.8.0. This is not due to any problem with this module; it is simply that Perl did not support printing to an in-memory file (\*(C`print \$string, "\n";\*(C') prior to that point. (Thanks to a \s-1CPAN\s0 testers report from David Cantrell for identifying this limitation.)

WARNING

The syntax and semantics of Perl 6 is still being finalized and consequently is at any time subject to change. That means the same caveat applies to this module.

DEPENDENCIES

No dependencies other than on modules included with the Perl core as of version 5.8.0.

Some of the files in the test suite accompanying this distribution use non-core \s-1CPAN\s0 module IO::Capture::Stdout. Tests calling IO::Capture::Stdout methods are enclosed in \*(C`SKIP\*(C' blocks and so should pose no obstacle to installation of the distribution on systems lacking IO::Capture. (However, the maintainer strongly recommends IO::Capture for developers who write a lot of test code. So please consider installing it!)

AUTHOR and MAINTAINER

Damian Conway ([email protected]). James E Keenan ([email protected]) (effective v0.06, July 2006).

ACKNOWLEDGMENTS

Thanks to Damian Conway for dreaming this up. Thanks to David A Golden for a close review of the documentation. Thanks to \s-1CPAN\s0 tester Jost Krieger for reporting an error in my \s-1SKIP\s0 block count in one test file.

BUGS AND IRRITATIONS

As far as we can determine, Perl 5 doesn't allow us to create a subroutine that truly acts like \*(C`print\*(C'. That is, one that can simultaneously be used like so:

say @data;

and like so:

say {$fh} @data;

Comments, suggestions, and patches welcome.

COPYRIGHT

Copyright (c) 2004, Damian Conway. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.