Mega Code Archive

 
Categories / Perl / Subroutine
 

My value scope

#!/usr/bin/perl use warnings; use strict; my $file_scope = "my value"; print $file_scope, "\n"; sub topsub {     my $top_scope = "visible in 'topsub'";     if (1 > 0.5) {         my $if_scope = "visible inside 'if'";         print "$file_scope, $top_scope, $if_scope \n";     }     bottomsub();     print "$file_scope, $top_scope\n"; } sub bottomsub {     my $bottom_scope = "visible in 'bottomsub'";     print "$file_scope, $bottom_scope \n"; } topsub(); print $file_scope, "\n";