programming-examples/perl/Subroutine/My value scope.pl
2019-11-15 12:59:38 +01:00

24 lines
507 B
Perl

#!/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";