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

#!/opt/perl588/bin/perl $city = Houston; print "$city is a decent place\n";
Why does this work? What other odd things can be done when not running under strict?
  • Comment on why does it work? Single bareword assignment to scalar under no strict
  • Download Code

Replies are listed 'Best First'.
Re: why does it work? Single bareword assignment to scalar under no strict
by Tanktalus (Canon) on Nov 10, 2010 at 18:59 UTC

    Did you check the strict documentation? Anything that that page says strict blocks, is something that is not blocked without strict.

Re: why does it work? Single bareword assignment to scalar under no strict
by JavaFan (Canon) on Nov 10, 2010 at 22:46 UTC
    Remember Perls origins. Perl was created to fill the gap between shell/awk on one side, and C on the other. It should have the best of both worlds. One of handy things of shell scripts is that you don't have to put quotes around single word strings, that is, stuff like cat file is valid, even if file is just a string argument.

    So, Perl got it as well. And because backwards compatibility is important, the default is to still allow it. So, without strict, Perl DWIM.

Re: why does it work? Single bareword assignment to scalar under no strict
by ikegami (Patriarch) on Nov 10, 2010 at 23:53 UTC
    What would be the point of strict if it stopped you from doing things you couldn't do anyway?