Skip to content

Instantly share code, notes, and snippets.

@hzhou
Created October 23, 2020 04:06
Show Gist options
  • Save hzhou/ece0fdac29d4fe04d23b72493822a4d4 to your computer and use it in GitHub Desktop.
Save hzhou/ece0fdac29d4fe04d23b72493822a4d4 to your computer and use it in GitHub Desktop.
Why Perl is better than Python - scope and variable declarations

Python does not have explicit variable declarations. It is implicitly created by the assignment. That means to understand a piece of code, specificly, to understand a life time of a variable, one has to hunt down the first occurence of assignment.

In Perl, with use strict, which should be on always, it is a simple matter of searching for keyword my or our. The life time of a local variable starts at the my $var to the end of the scope, period.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment