This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
-s on #! line
[perl5.git] / toke.c
diff --git a/toke.c b/toke.c
index ae44e89..b5e6b9c 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2688,6 +2688,7 @@ Perl_yylex(pTHX)
                    while (SPACE_OR_TAB(*d)) d++;
 
                    if (*d++ == '-') {
+                       bool switches_done = PL_doswitches;
                        do {
                            if (*d == 'M' || *d == 'm') {
                                char *m = d;
@@ -2711,6 +2712,14 @@ Perl_yylex(pTHX)
                                (void)gv_fetchfile(PL_origfilename);
                            goto retry;
                        }
+                       if (PL_doswitches && !switches_done) {
+                           int argc = PL_origargc;
+                           char **argv = PL_origargv;
+                           do {
+                               argc--,argv++;
+                           } while (argc && argv[0][0] == '-' && argv[0][1]);
+                           init_argv_symbols(argc,argv);
+                       }
                    }
                }
            }