Duplicate global and local variable name (use strict;) : Local « Subroutine « Perl






Duplicate global and local variable name (use strict;)

   


#!/usr/bin/perl -w

use strict;

$record = 4;
print "We're at record ", $record, "\n";

{
    my $record;
    $record = 7;
    print "Inside the block:", $record, "\n";
}

print "Outside, we're still at record ", $record, "\n";

   
    
    
  








Related examples in the same category

1.Local variable shadows the gloabl variable
2.Local variable shadows the global variable in a subroutine
3.Local variables in subroutines
4.Difference between my and local
5.Using local