pR |OP* |ck_rfun |NN OP *o
pR |OP* |ck_rvconst |NN OP *o
pR |OP* |ck_sassign |NN OP *o
-pR |OP* |ck_say |NN OP *o
pR |OP* |ck_select |NN OP *o
pR |OP* |ck_shift |NN OP *o
pR |OP* |ck_sort |NN OP *o
#define ck_rfun Perl_ck_rfun
#define ck_rvconst Perl_ck_rvconst
#define ck_sassign Perl_ck_sassign
-#define ck_say Perl_ck_say
#define ck_select Perl_ck_select
#define ck_shift Perl_ck_shift
#define ck_sort Perl_ck_sort
#define ck_rfun Perl_ck_rfun
#define ck_rvconst Perl_ck_rvconst
#define ck_sassign Perl_ck_sassign
-#define ck_say Perl_ck_say
#define ck_select Perl_ck_select
#define ck_shift Perl_ck_shift
#define ck_smartmatch Perl_ck_smartmatch
#define ck_rfun(a) Perl_ck_rfun(aTHX_ a)
#define ck_rvconst(a) Perl_ck_rvconst(aTHX_ a)
#define ck_sassign(a) Perl_ck_sassign(aTHX_ a)
-#define ck_say(a) Perl_ck_say(aTHX_ a)
#define ck_select(a) Perl_ck_select(aTHX_ a)
#define ck_shift(a) Perl_ck_shift(aTHX_ a)
#define ck_sort(a) Perl_ck_sort(aTHX_ a)
#define ck_rfun(a) Perl_ck_rfun(aTHX_ a)
#define ck_rvconst(a) Perl_ck_rvconst(aTHX_ a)
#define ck_sassign(a) Perl_ck_sassign(aTHX_ a)
-#define ck_say(a) Perl_ck_say(aTHX_ a)
#define ck_select(a) Perl_ck_select(aTHX_ a)
#define ck_shift(a) Perl_ck_shift(aTHX_ a)
#define ck_smartmatch(a) Perl_ck_smartmatch(aTHX_ a)
}
OP *
-Perl_ck_say(pTHX_ OP *o)
-{
- o = ck_listiob(o);
- o->op_type = OP_PRINT;
- cLISTOPo->op_last = cLISTOPo->op_last->op_sibling
- = newSVOP(OP_CONST, 0, newSVpvs("\n"));
- return o;
-}
-
-OP *
Perl_ck_smartmatch(pTHX_ OP *o)
{
dVAR;
MEMBER_TO_FPTR(Perl_ck_null), /* break */
MEMBER_TO_FPTR(Perl_ck_null), /* continue */
MEMBER_TO_FPTR(Perl_ck_smartmatch), /* smartmatch */
- MEMBER_TO_FPTR(Perl_ck_say), /* say */
+ MEMBER_TO_FPTR(Perl_ck_listiob), /* say */
MEMBER_TO_FPTR(Perl_ck_null), /* custom */
}
#endif
continue continue ck_null 0
smartmatch smart match ck_smartmatch s2
-say say ck_say ims@ F? L
+say say ck_listiob ims@ F? L
# Add new ops before this, the custom operator.
=item say
Just like C<print>, but implicitly appends a newline.
-C<say LIST> is simply an abbreviation for C<print LIST, "\n">,
-and C<say()> works just like C<print($_, "\n")>.
-
-That means that a call to say() appends any output record separator
-I<after> the added newline.
+C<say LIST> is simply an abbreviation for C<{ local $/ = "\n"; print
+LIST }>.
This keyword is only available when the "say" feature is
enabled: see L<feature>.
Perl_ck_rfun
Perl_ck_rvconst
Perl_ck_sassign
-Perl_ck_say
Perl_ck_select
Perl_ck_shift
Perl_ck_smartmatch
if (MARK <= SP)
goto just_say_no;
else {
- if (PL_ors_sv && SvOK(PL_ors_sv))
+ if (PL_op->op_type == OP_SAY) {
+ if (PerlIO_write(fp, "\n", 1) == 0 || PerlIO_error(fp))
+ goto just_say_no;
+ }
+ else if (PL_ors_sv && SvOK(PL_ors_sv))
if (!do_print(PL_ors_sv, fp)) /* $\ */
goto just_say_no;
PERL_CKDEF(Perl_ck_rfun)
PERL_CKDEF(Perl_ck_rvconst)
PERL_CKDEF(Perl_ck_sassign)
-PERL_CKDEF(Perl_ck_say)
PERL_CKDEF(Perl_ck_select)
PERL_CKDEF(Perl_ck_shift)
PERL_CKDEF(Perl_ck_smartmatch)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_1);
-PERL_CALLCONV OP* Perl_ck_say(pTHX_ OP *o)
- __attribute__warn_unused_result__
- __attribute__nonnull__(pTHX_1);
-
PERL_CALLCONV OP* Perl_ck_select(pTHX_ OP *o)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_1);
use feature "say";
-say "1..11";
+say "1..12";
my $foo = 'STDOUT';
say $foo "ok 1";
$_ = "ok 11";
say STDOUT;
+
+{
+ # test that $, doesn't show up before the trailing \n
+ local $, = "\nnot ok 13"; # how to fool Test::Harness
+ say "ok 12";
+}