summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-09-17 23:18:08 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-09-17 23:20:26 -0700
commit8561ea1dd1a3357825e765e1df4f883e53f89a9d (patch)
treefd16385d6265ed60c2ceb1e718f0c37d0ec14d0c /mg.c
parent79bffe477e0016f596b86950244ad3a10a753e58 (diff)
downloadperl-8561ea1dd1a3357825e765e1df4f883e53f89a9d.tar.gz
${^LAST_FH}
This was brought up in ticket #96672. This variable gives access to the last-read filehandle that Perl uses when it appends ", <STDIN> line 1" to a warning or error message.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/mg.c b/mg.c
index 26cabbe627..cbae421358 100644
--- a/mg.c
+++ b/mg.c
@@ -906,6 +906,20 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
case '\011': /* ^I */ /* NOT \t in EBCDIC */
sv_setpv(sv, PL_inplace); /* Will undefine sv if PL_inplace is NULL */
break;
+ case '\014': /* ^LAST_FH */
+ if (strEQ(remaining, "AST_FH")) {
+ if (PL_last_in_gv) {
+ assert(isGV_with_GP(PL_last_in_gv));
+ SV_CHECK_THINKFIRST_COW_DROP(sv);
+ prepare_SV_for_RV(sv);
+ SvOK_off(sv);
+ SvRV_set(sv, SvREFCNT_inc_simple_NN(PL_last_in_gv));
+ SvROK_on(sv);
+ sv_rvweaken(sv);
+ }
+ else sv_setsv_nomg(sv, NULL);
+ }
+ break;
case '\017': /* ^O & ^OPEN */
if (nextchar == '\0') {
sv_setpv(sv, PL_osname);