Subroutines, Packages and Modules
时间:2008-01-17 来源:xiaoaizhen
&SUBROUTINE LIST Executes a SUBROUTINE declared by a sub declaration, and returns the value of the last expression evaluated in SUBROUTINE. SUBROUTINE can be an expression yielding a reference to a code object. The & may be omitted if the subroutine has been declared before being used. bless REF [ , PACKAGE ] Turns the object REF into an object in PACKAGE. Returns the reference. caller [ EXPR ] Returns an array ($package,$file,$line,...) for a specific subroutine call. caller returns this info for the current subroutine, caller(1) for the caller of this subroutine, etc. Returns false if no caller. do SUBROUTINE LIST Deprecated form of &SUBROUTINE. goto &SUBROUTINE Substitutes a call to SUBROUTINE for the current subroutine. import MODULE [ [ VERSION ] LIST ] Imports the named subroutines from MODULE. no MODULE [ LIST ] Cancels imported semantics. See use. package NAME Designates the remainder of the current block as a package. require EXPR† If EXPR is numeric, requires Perl to be at least that version. Otherwise EXPR must be the name of a file that is included from the Perl library. Does not include more than once, and yields a fatal error if the file does not evaluate to a true value. If EXPR is a bare word, assumes extension .pm for the name of the file. return EXPR Returns from a subroutine with the value specified. sub NAME { EXPR ; ... } Designates NAME as a subroutine. Parameters are passed by reference as array @_. Returns the value of the last expression evaluated. [ sub ] BEGIN { EXPR ; ... } Defines a setup BLOCK to be called before execution. [ sub ] END { EXPR ; ... } Defines a cleanup BLOCK to be called upon termination. tie VAR, PACKAGE, [ LIST ] Ties a variable to a package that will handle it. Can be used to bind a dbm or ndbm file to a hash. untie VAR Breaks the binding between the variable and the package. use MODULE [ [ VERSION ] LIST ] Imports semantics from the named module into the current package.
相关阅读 更多 +
排行榜 更多 +