package Perl6::say; use base 'Exporter'; @EXPORT = 'say';
sub say { print @_, "\n"; } 1
__END__
=head1 NAME
Perl6::say - Perl extension to get say in Perl 5
=head1 DESCRIPTION
DWYM :)
=head2 Exported list operators
=head3 say
C<print>s its arguments and "\n";
=head1 CAVEATS
Does not support printing to filehandles that are not currently C<sele
+ct>ed (one arg).
=head1 SEE ALSO
L<perlfunc/print>
:) | [reply] [d/l] |
I've tried Perl6::Say, but found it wanting.
The list of caveats regarding the type of filehandles it will work with is annoying. I tend to store file handles in hash elements quite frequently, and use indirect object notation print { $fhs{INPUT} } $stuff;, and that doesn't work with P6::Say.
I'm not ready to give up the simplicity of that notation and move to $fhs{INPUT}->say .... If filehandles were truely OO constructs, complete with independant settings for $/, $\, $=, $., $^ etc. etc., then it would be a different matter...but they aren't.
If say were implemented within the language, it would be barely any code at all. Just a stub sub, pp_say, that localised $\ and set it to "\n", and then calls pp_print() would probably be all was required, but it would 'Just work'.
I think it would be a very useful addition to Perl5--but then I'm biased against having to add zillions of ."\n"s :)
Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
| [reply] [d/l] [select] |
I'd definitely like to see say in Perl 5. After the // operator (which is already slated for 5.10), I think say is probably the biggest "bang-for-the-buck" in all of Perl 6.
As for Perl6::Say being "wanting", I would agree. Unfortunately, Perl 5's import and subroutine prototype mechanisms aren't quite up to the task of implementing a full print-like syntax. If only I could do it in Perl 6. Oh, wait...
;-)
| [reply] |
Isn't say just as simple as adding 'say' as a keyword to keywords.pl in the Perl source, recompiling, then doing:
*CORE::GLOBAL::say = sub { print @_, $/ };
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] [d/l] |
| [reply] [d/l] |