Wednesday, October 19, 2022

Pass by value example in perl

 

sub cube {    
  my $num1 = @_[0];     #num1 parameter passed by value here
  return $num1 * $num1 * $num1; #cube of num1 returned
}





$answer = cube(3); #function cube called with 3 passed as the argument
print $answer ;


No comments:

Post a Comment