Scope of variables


Variables defined within a block {} are hiding more global variables with the same name. They are destructed when leaving the block.


examples/scalars/scope1.pl
#!/usr/bin/perl
use strict;
use warnings;

{
    my $email = 'foo@bar.com';
    print "$email\n";     # foo@bar.com
}
# print $email;
# $email does not exists
# Global symbol "$email" requires explicit package name at ...