my $value = "four"; # lexical variable my @array = ( "one", "two", "three" ); foreach $value (@array) { # variable $value inside the loop is set # to each element of @array at runtime print "foreach value: $value\t"; function(); } # outer scope lexical $value visible here sub function { # outer scope lexical $value visible here # with its initial value print "function value: $value\n"; }