此函数声明LIST中的变量在包围式块内按词法范围。如果指定了多个变量,则所有变量都必须用括号括起来。
以下是此函数的简单语法-
my LIST
此函数不返回任何值。
链接:https://www.learnfk.com/perl/perl-my.html
来源:LearnFk无涯教程网
以下是显示其基本用法的示例代码-
#!/usr/bin/perl -w my $string = "We are the world"; print "$string\n"; myfunction(); print "$string\n"; sub myfunction { my $string = "We are the function"; print "$string\n"; mysub(); } sub mysub { print "$string\n"; }
执行上述代码后,将产生以下输出-
We are the world We are the function We are the world We are the world
这一章《Perl - my函数》你学到了什么?在下面做个笔记吧!做站不易,你的分享是对我们最大的支持,感谢!😊
Flutter 错误:找不到成员:'UnicodeChar'
如何在混合数据类型的 Python Pandas 数据框列中仅比较日期或仅...