Perl | return() Function Last Updated : 07 May, 2019 Comments Improve Suggest changes Like Article Like Report return() function in Perl returns Value at the end of a subroutine, block, or do function. Returned value might be scalar, array, or a hash according to the selected context. Syntax: return Value Returns: a List in Scalar Context Note: If no value is passed to the return function then it returns an empty list in the list context, undef in the scalar context and nothing in void context. Example 1: Perl #!/usr/bin/perl -w # Subroutine for Multiplication sub Mul($$) { my($a, $b ) = @_; my $c = $a * $b; # Return Value return($a, $b, $c); } # Calling in Scalar context $retval = Mul(25, 10); print ("Return value is $retval\n" ); # Calling in list context @retval = Mul(25, 10); print ("Return value is @retval\n" ); Output: Return value is 250 Return value is 25 10 250 Example 2: Perl #!/usr/bin/perl -w # Subroutine for Subtraction sub Sub($$) { my($a, $b ) = @_; my $c = $a - $b; # Return Value return($a, $b, $c); } # Calling in Scalar context $retval = Sub(25, 10); print ("Return value is $retval\n" ); # Calling in list context @retval = Sub(25, 10); print ("Return value is @retval\n" ); Output: Return value is 15 Return value is 25 10 15 Comment More infoAdvertise with us Next Article Perl | return() Function C Code_Mech Follow Improve Article Tags : Perl perl-basics Perl-function Perl-Inbuilt-Functions Similar Reads Function Signature in Perl A Perl function or subroutine is a group of statements that together perform a specific task. In every programming language user want to reuse the code. So the user puts the section of code in function or subroutine so that there will be no need to write code again and again. In Perl, the terms func 5 min read Recursion in Perl Recursion is a mechanism when a function calls itself again and again till the required condition is met. When the function call statement is written inside the same function then such a function is referred to as a recursive function.The argument passed to a function is retrieved from the default a 3 min read Perl | Subroutines or Functions A Perl function or subroutine is a group of statements that together perform a specific task. In every programming language user want to reuse the code. So the user puts the section of code in function or subroutine so that there will be no need to write code again and again. In Perl, the terms func 2 min read Perl | Tail Calls in Function Recursion Recursion in Perl is any function that does not uses the for loop or the while loop, instead calls itself during the execution of the program and the corresponding function is known as recursive function. Tail recursive function is a special case of recursion in which the function call statement is 5 min read Perl - Closure Function Closure is one of the important concepts in Perl. Closure is a computer term with an accurate but a hard to explain meaning. It is often referred as a function that can be stored as a variable, which has a special ability to access other variables local to the scope it was created in. It is used to 5 min read Perl | Scope of a Subroutine Subroutines in Perl, are reusable unit of code. It is a dynamic concept. Functions and subroutines are the two terms that can be used interchangeably. If you want to be strict on the semantics, small pieces of named blocks of code that accept arguments and return values are called subroutines. The b 7 min read return command in Linux with examples return command is used to exit from a shell function. It takes a parameter [N], if N is mentioned then it returns [N] and if N is not mentioned then it returns the status of the last command executed within the function or script. N can only be a numeric value. The return command is especially usefu 2 min read Return Statement in C Pre-requisite: Functions in C C return statement ends the execution of a function and returns the control to the function from where it was called. The return statement may or may not return a value depending upon the return type of the function. For example, int returns an integer value, void retur 4 min read return Statement in C++ In C++, the return statement returns the flow of the execution to the function from where it is called. This statement does not mandatorily need any conditional statements. As soon as the statement is executed, the flow of the program stops immediately and returns the control from where it was calle 4 min read Return Value from R Function In this article, we will discuss how to return value from a function in R Programming Language. Method 1: R function with return value In this scenario, we will use the return statement to return some value Syntax: function_name <- function(parameters) {    statements  return(value) } function 2 min read Like