You could create an alias in your current package:*printScreen = \&SettingsGeneral::printScreen;printScreen("another urgent flash\n");跳过括号(这是必需的,因为当前包中的sub在编译时未知)Skip the parentheses (necessary because the sub in the current package wasn't known at compile time) by writing:use subs 'printScreen';*printScreen = \&SettingsGeneral::printScreen;printScreen "the sky is falling!\n"; 导出器模块可以为您完成以下托管工作:The Exporter module can do this custodial work for you: SettingsGeneral.pm:package SettingsGeneral;use Exporter 'import';our @EXPORT = qw/ printScreen /;sub printScreen { print $_[0];}1; 主要:#! /usr/bin/perluse warnings;use strict;use SettingsGeneral;printScreen "foo!\n"; 这篇关于如何引用Perl子例程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-13 08:20