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

I recently got portable Strawberry perl on my system, and was trying to test it out with a very simple script:
!# perl -w use strict; my $myVariable="hello, world"; print $myVariable;
If I use the Use strict, I get ""use" not allowed in expression at line 2" If I take strict out, I receive a "Can't modify not in scalar assignment". I'm really not sure why this doesn't work.

Replies are listed 'Best First'.
Re: Easy script question
by pryrt (Abbot) on Mar 01, 2018 at 17:21 UTC
    !#perl -w

    your shebang was inverted. should be

    #!perl -w
      Thank you!
        Oh, I'm so glad to know that I'm not the only person in this world who has actually done that. ("D'oh!")
Re: Easy script question
by Laurent_R (Canon) on Mar 01, 2018 at 17:47 UTC
    In addition to your error pointed out by pryrt, I would suggest that it probably does not make very much sense to have a shebang line with Windows. Except, of course, that it enables you to use the -w flag. But it is probably better to use the use warnings pragma and to start your program with:
    use strict; use warnings;