Skip to content

Instantly share code, notes, and snippets.

@gatlin
Created June 27, 2012 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gatlin/3002199 to your computer and use it in GitHub Desktop.
Save gatlin/3002199 to your computer and use it in GitHub Desktop.
Extremely basic example of lexical scope use in Perl
#!/usr/bin/env perl
use v5.16;
use strict;
use warnings;
sub c {
my $lexicalValue = 0;
return sub {
say $lexicalValue;
$lexicalValue++;
}
}
my $fn = c;
$fn->();
$fn->();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment