# In your subroutines, you can access the value of any global variable.
# A global variable is a variable that is accessible across the entire Perl script.
# A subroutine can use data set up by other parts of your Perl scripts:
#!/usr/bin/perl -w
# Accessing global variables in subroutines.
$a = 1;
$b = 4;
$value = add();
print "$a plus $b is $value.\n";
sub add {
return ($a + $b);
}
# sub3.pl
|