in reply to Re^2: Perl Errors
in thread Perl Errors
Yes. You use my to declare a new variable in a scope (file, curly braces). So this:
my $fruit = 'apple'; { my $fruit = 'banana'; print "$fruit\n"; } print "$fruit\n";
should print apple and banana, because you have *two* variables named $fruit. While you're within the curly braces, the second one masks (hides) the first one. If you remove the second 'my', then it should print banana and banana, since you're using the same variable.
Note: I didn't test the code.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|