Perl代码示例与调试指南
1. 更多Perl代码示例
理解Perl命令工作原理的最佳方式是剖析一个可运行的脚本。下面通过一个“动手尝试”的例子来进行说明。
1.1 检查标准输入
1.1.1 编写脚本
使用文本编辑器输入以下脚本,将其保存为 check.pl ,并更改权限以允许脚本执行。
#!/usr/bin/perl -T
# check.pl
# A Perl script that checks the input to determine if
# it contains numeric information
# First set up your Perl environment and import some useful Perl packages
use warnings;
use diagnostics;
use strict;
my $result;
# Next check for any input and then call the proper subroutine
# based on the test
if (@ARGV) {
# If the test condition for data from standard in is true run
# the test subroutine on the input data
$result = &test;
} else {
# else the test condition is false and you shoul
超级会员免费看
订阅专栏 解锁全文
7

被折叠的 条评论
为什么被折叠?



