$mail->say($textecourriel);
as a preferred syntax.
Update:
See responses for why I have striken this recommendation.
| [reply] [d/l] [select] |
open( my $mail, "| mailx -r $from -s $sujet $courrielclient");
... in this case, $mail actually is the file handle case :) | [reply] [d/l] [select] |
That's all wrong.
say $mail $textecourriel; is NOT an instance of indirect method call syntax. It's not a method call at all. It's a named operator with a funky syntax.
The indirect feature has no effect on this. (Neither does the indirect pragma.)
It does NOT confuse the Perl interpreter (because say is always declared, and because the handle expression is limited to a simple scalar, a bareword (if you use the bareword_filehandles anti-feature), or a block).
Unlike say $mail $textecourriel;, $mail->say( $textecourriel ); does invoke a method (of IO::Handle). This adds needless overhead and complexity. This is what should be avoided.
The IO::Handle::say method doesn't use say. It instead emulates it using local $\ = "\n"; and print. This is not equivalent in an (admittedly obscure) corner case.
The IO::Handle::say method ends up using print $mail $textecourriel; anyway. Because that's how one prints to a file handle in Perl. It's not something to avoid as you suggest.
If it's in perlfunc, it's not a method call. As such, none of the following are instances of indirect method call syntax:
- print FH LIST
- print BLOCK LIST
- printf FH LIST
- printf BLOCK LIST
- say FH LIST
- say BLOCK LIST
- map BLOCK LIST
- grep BLOCK LIST
- system BLOCK LIST
- exec BLOCK LIST
| [reply] [d/l] [select] |
| [reply] |