Help for this page

Select Code to Download


  1. or download this
    pritesh@mintpad ~ $ more test_var_loc.pl 
    use strict;
    ...
    second();
    print "After second function,  \$val is $val stored at ", \$val, "\n";
    pritesh@mintpad ~ $
    
  2. or download this
    pritesh@mintpad ~ $ perl test_var_loc.pl 
    Outside the functions $val is 10 stored at SCALAR(0x1c307c8)
    ...
    In the second function $val is 100 stored at SCALAR(0x1c307c8)
    After second function,  $val is 100 stored at SCALAR(0x1c307c8)
    pritesh@mintpad ~ $
    
  3. or download this
    pritesh@mintpad ~ $ more test_my_var_loc.pl 
    use strict;
    ...
    print "After first function, before second function,  \$val is $val st
    +ored at ", \$val, "\n";
    second();
    print "After second function,  \$val is $val stored at ", \$val, "\n";
    
  4. or download this
    pritesh@mintpad ~ $ perl test_my_var_loc.pl 
    Outside the functions $val is 10 stored at SCALAR(0xb2d7c8)
    ...
    In the second function $val is 100 stored at SCALAR(0xb2e290)
    After second function,  $val is 10 stored at SCALAR(0xb2d7c8)
    pritesh@mintpad ~ $