We've already seen how to use an anonymous subroutine or a reference to a named subroutine.
我们已经看到如何使用匿名的子例程或者对指定子例程的引用。
The dispatcher can either contain the actual code used to deal with a particular element as an anonymous subroutine or it can contain a reference to a named subroutine defined elsewhere.
分派表可以包含用来处理特定元素的实际代码(匿名子例程),也可以包含对别处定义的命名子例程的引用。
Listing 4 shows the printPassword subroutine, which is used to print out the password keys and timings for reference.
清单4显示了printpassword子例程,该子例程用于输出密码键和计时以供参考。
Note that a reference to AppConfig is also passed to the subroutine so other variable changes can be triggered by one single change.
对AppConfig 的引用也被传送到子例程,所以单个更改会触发其它变量更改。
If instead we wanted to register an arbitrary subroutine (defined using sub method_name{ ... }), we would have to register a reference to this subroutine like so: -command=>\&method_name.
如果不采用这种方法的话,我们要想注册一个子例程(用 sub method_name{ ... }来定义),那么必须注册一个到这个子例程的引用,类似于: -command=>\&method_name 。
If instead we wanted to register an arbitrary subroutine (defined using sub method_name{ ... }), we would have to register a reference to this subroutine like so: -command=>\&method_name.
如果不采用这种方法的话,我们要想注册一个子例程(用 sub method_name{ ... }来定义),那么必须注册一个到这个子例程的引用,类似于: -command=>\&method_name 。
应用推荐