目录

local

描述 (Description)

此函数将LIST中的变量设置为当前执行块的本地变量。 如果指定了多个值,则必须使用括号来定义列表。

请注意,local创建变量的本地副本,然后在封闭块终止时超出范围。 无论何时访问本地化值,都会使用本地化值,包括该块期间使用的任何子例程和格式。

语法 (Syntax)

以下是此函数的简单语法 -

local LIST

返回值 (Return Value)

此函数不返回任何值。

例子 (Example)

以下是显示其基本用法的示例代码 -

#!/usr/bin/perl -w
local $foo;			      # make $foo dynamically local
local (@wid, %get);		# make list of variables local
local $foo = "flurp";	  # make $foo dynamic, and init it
local @oof = @bar;		# make @oof dynamic, and init it
↑回到顶部↑
WIKI教程 @2018