Login
Remember
Register
Ask a Question
Create a function that is only available inside the scope where it is defined?
+1
vote
asked
Jul 26, 2023
in
Perl
by
Robin
Create a function that is only available inside the scope where it is defined?
perl-function
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Jul 26, 2023
by
Robin
$pvt = Calculation(5,5);
print("Result = $pvt\n");
sub Calculation{
my ($fstVar, $secndVar) = @_;
my $square = sub{
return($_[0] ** 2);
};
return(&$square($fstVar) + &$square($secndVar));
};
Output: Result = 50
...