in reply to Basic Print statement question
use strict; use warnings; my $variable = 1; print $variable; subroutine(); sub subroutine { my $variable = 2; print $variable; } #Output: #12
Each print prints the value of the $variable it's closest to (in this example only, it's not a rule).
I fairly sure you will benefit from reading Coping with Scoping. It'll help you understand Perl's notion of global and local variables.
|
|---|