belg4mit has asked for the wisdom of the Perl Monks concerning the following question:

I was playing golf with First JAPH - Spell perl in two hundred and eighty five thousand and seventy four easy steps, and arrived at:
#!/usr/bin/perl -wMstrict my$A="a";$A++for(0..285074);print$A;
But I get Too late for "-Mstrict" option at /tmp/b line 1.. And I can't figure out why...

--
perl -pe "s/\b;([st])/'\1/mg"

Edit kudra, 2002-01-10 Added to title

Replies are listed 'Best First'.
Re: Too late for
by Kanji (Parson) on Jan 10, 2002 at 14:50 UTC

    From perldoc perldiag ...

    Too late for "-%s" option
    (X) The #! line (or local equivalent) in a Perl script contains the -M or -m option. This is an error because -M and -m options are not intended for use inside scripts. Use the "use" pragma instead.

        --k.


      Well yes, but there's no inherent reason why it shouldn't work unlike -T. Apparently I have reports iof it working on 5.005.03 and 5.6.1, whereas I am using 5.6.0 (should have noted that in the original post).

      UPDATE: There was a bit of confusion with whom I spake, it does not work with neither 5.005.03 nor 5.6.1. IMHO it still ought to though ;-)

      --
      perl -pe "s/\b;([st])/'\1/mg"

Re: Too late for
by rendler (Pilgrim) on Jan 10, 2002 at 14:51 UTC
    you'll be wanting either
    #!/usr/bin/perl -w use strict; my $A="a";$A++for(0..285074);print$A;
    or at the command line
    perl -Mstrict -le 'my $A="a";$A++for(0..285074);print$A;'
    Or in both cases withouth the strict pragma in use you can drop the my declaration on $A