Front page | perl.perl5.porters |
Postings from July 2001
[PATCH toke.c] autosplit into @F
From:
Robin Houston
Date:
July 2, 2001 15:20
Subject:
[PATCH toke.c] autosplit into @F
Message ID:
E15HC3M-0007jL-00.2001-07-02-23-20-24@mail18.svr.pol.co.uk
Simon Cozens told me about possibly the most obscure bug yet in
B::Deparse.
If you run something like
./perl -Ilib -MO=Deparse -Mstrict -lane1
then the output contains references to @F, without declaring it as C<my>
or fully-qualifying it. So it fails to compile, because of the "strict"
hint.
The following patch to toke.c replaces the rather Deep Magic approach to
declaring @F with some shallower magic (i.e. our).
(The same caveats about word-wrapping apply, with conditional consequent
apologies.)
.robin.
--- toke.c.orig Mon Jul 2 22:01:14 2001
+++ toke.c Mon Jul 2 22:32:41 2001
@@ -2545,9 +2545,6 @@
if (PL_minus_l)
sv_catpv(PL_linestr,"chomp;");
if (PL_minus_a) {
- GV* gv = gv_fetchpv("::F", TRUE, SVt_PVAV);
- if (gv)
- GvIMPORTED_AV_on(gv);
if (PL_minus_F) {
if (strchr("/'\"", *PL_splitstr)
&& strchr(PL_splitstr + 1, *PL_splitstr))
@@ -2557,7 +2554,7 @@
s = "'~#\200\1'"; /* surely one char is unused...*/
while (s[1] && strchr(PL_splitstr, *s)) s++;
delim = *s;
- Perl_sv_catpvf(aTHX_ PL_linestr, "@F=split(%s%c",
+ Perl_sv_catpvf(aTHX_ PL_linestr, "our @F=split(%s%c",
"q" + (delim == '\''), delim);
for (s = PL_splitstr; *s; s++) {
if (*s == '\\')
@@ -2568,7 +2565,7 @@
}
}
else
- sv_catpv(PL_linestr,"@F=split(' ');");
+ sv_catpv(PL_linestr,"our @F=split(' ');");
}
}
sv_catpv(PL_linestr, "\n");
--- perl.c.orig Mon Jul 2 21:59:38 2001
+++ perl.c Mon Jul 2 22:22:36 2001
@@ -2037,7 +2037,7 @@
S_usage(pTHX_ char *name) /* XXX move this out into a module ? */
{
/* This message really ought to be max 23 lines.
- * Removed -h because the user already knows that opton. Others? */
+ * Removed -h because the user already knows that option. Others? */
static char *usage_msg[] = {
"-0[octal] specify record separator (\\0, if no argument)",
-
[PATCH toke.c] autosplit into @F
by Robin Houston