#!/usr/bin/perl #Is you is, or is you ain't, my foobar? #The dope on scope. baz(); #call baz. sub baz { my $foobar="I feel Baz!\n"; print $foobar; #$foobar is now lexically scoped for #the whole subroutine block. if (1) { #This is another block, it belongs to if. my $foobar="I am the FooMan!\n"; print $foobar; #$foobar is now lexically scoped #for this if block; } print $foobar; if ("I own several pairs of pants") { #That ^^^^ is another if, and this is its block my $foobar="I am the BarMan!\n"; print $foobar; #$foobar is now lexically scoped for this if block; } print $foobar; }