In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to receive the parameters of the Perl function, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Parameter receiving method of Perl function
Pick Perl again
Original: http://www.linuxsir.org/bbs/showthread.php?t=78216
Perl function and scope
Syntax:
SubsubroutineName
{
The my (@ argsTosubroutine) = @ _; # argument is passed to the Perl function in this way
& doStuff;# executor
Return (@ returnValue); #
}
The special variable @ _ is the parameter stack, which is local data for the called subroutine. Put the parameters into @ _ each time the subroutine is called. @ _ works much like the stacks in c and C++. Because the parameter stack is an array, there is no limit to the number of arguments passed to the Perl function. And every parameter is a scalar. When a subroutine is called, the length of the parameter stack is irrelevant. No matter what parameter is passed to the reader's subroutine, Perl will be responsible for generating @ _, and the subPerl function will decide whether to accept the parameter or not.
◆ operation parameter stack:
In Perl, the subscript of any array starts at 0.)
@ _, like other types of arrays, can be accessed through subscripts.
You can also use the shift and popPerl functions to access @ _. Shift and pop actually mean that shift (@ _) pop (@ _) is two Perl functions that operate on the parameter stack. Indicates whether the parameter stack is manipulated from the top or bottom of the stack. Each time they are called, they take * parameters (shift) or do the latter parameter (pop). Then shorten @ _ as you continue execution by storing the parameter in the variable on the left.
Local @ _ stack. This feature allows the Perl function to be called within a Perl function without having to worry about the impact of the Perl function at this level on the lower-level Perl function. This flexibility allows Perl to use recursive programs
The return value stack is the way Perl returns the value to the caller of the subroutine. @ values=subroutine ($arguments). Like the parameter stack, the return value stack is also an array.
There are two main ways for the child Perl function to return the value to the main Perl function:
◆ uses a special Perl function to return
◆ uses the default method (that is, look at an expression of the subroutine).
1.Return keyword
The Return keyword allows you to immediately break the sub-Perl function and return the value inside the parameter stack to the calling Perl function.
2. Return by default
If there is no return statement in the Perl function, the * sentence of the subroutine actually returns the value stack
3.Wantarray
The Perl function is the Perl function in Perl that can make the sub-Perl function perform dual responsibilities. Wantarray can determine whether a Perl function is used in an array or scalar environment.
Thank you for reading this article carefully. I hope the article "how to receive the parameters of Perl function" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.