By default, all variables in Perl are global variables; that is, they are accessible from every part of the program, unless you declare with "my" to create a "lexical" (local) varable.
Select one:
True
False
Answer: Hey!! Kindly finds your solution below. Let me know if any issue.Thanks.
It’s a TRUE statement. In Perl, we use keyword my to create a lexical or local variable that we can use within a block.
Ex.
Use strict;
Use warnings;
If (3>4)
{
my $score = 50; #local variable declaration with my keyword
print “$Score\n”;
}
Without declaration using variable are global variables by default in Perl, they can be used anywhere in program. (my keyword is not used to declare)
Ex.
use warnings;
If (3>4)
{
$score = 50; #no declaration with my keyword
print “$Score\n”;
}
print “$Score\n”; #accessible outside the block
Get Answers For Free
Most questions answered within 1 hours.