From: Simon Cozens Date: Wed, 27 Dec 2000 05:08:57 +0000 (+0000) Subject: Interesting syntax idea X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d38a0a1467f89c02cbd16ebdc31b41c6b552f379;p=p5sagit%2Fp5-mst-13.2.git Interesting syntax idea Message-ID: <20001227050857.A11296@deep-dark-truthful-mirror.perlhacker.org> Make opens + bareword assigns do typeglob assigns. p4raw-id: //depot/perl@8254 --- diff --git a/op.c b/op.c index 215b85c..28e7e98 100644 --- a/op.c +++ b/op.c @@ -1336,6 +1336,31 @@ Perl_mod(pTHX_ OP *o, I32 type) PL_modcount++; return o; case OP_CONST: + if (o->op_private & (OPpCONST_BARE) && + !(type == OP_GREPSTART || type == OP_ENTERSUB || type == OP_REFGEN)) { + SV *sv = ((SVOP*)o)->op_sv; + GV *gv; + + /* Could be a filehandle */ + if (gv = gv_fetchpv(SvPV_nolen(sv), FALSE, SVt_PVIO)) { + OP* gvio = newUNOP(OP_RV2GV, 0, newGVOP(OP_GV, 0, gv)); + op_free(o); + o = gvio; + } else { + /* OK, it's a sub */ + OP* enter; + gv = gv_fetchpv(SvPV_nolen(sv), TRUE, SVt_PVCV); + + enter = newUNOP(OP_ENTERSUB,0, + newUNOP(OP_RV2CV, 0, + newGVOP(OP_GV, 0, gv) + )); + enter->op_private |= OPpLVAL_INTRO; + op_free(o); + o = enter; + } + break; + } if (!(o->op_private & (OPpCONST_ARYBASE))) goto nomod; if (PL_eval_start && PL_eval_start->op_type == OP_CONST) {