Saturday, February 14, 2015

Crappy, Crappy Perl : Subroutine Vars Access Globals By Default

Man, after 15+ years of using perl, you'd guess I should be aware of such a shortcoming.

You can do

sub mySub () {
    $var = 'xyz';
}

And, if there's a variable in the body called $var, you're in big trouble mate!

You *have* to use strict. Stinks..

By default, subroutine vars should be local. Anyone knows that.. Shame on your Larry..

No comments: