Skip to content

Instantly share code, notes, and snippets.

@jreisinger
Last active September 30, 2015 04:38
Show Gist options
  • Save jreisinger/1723314 to your computer and use it in GitHub Desktop.
Save jreisinger/1723314 to your computer and use it in GitHub Desktop.
Global variable vs. function with argumet
#
# 1. global variable
#
my $num = 2;
exp();
sub exp {
return $num * $num;
}
#
# 2. function with argument
#
my $num = 2;
exp($num);
sub exp {
my $num = shift; # local to exp
return $num * $num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment