一个签到函数
来源:互联网 发布:知乎手机版怎么引用 编辑:程序博客网 时间:2024/05/01 21:24
[root@mysql1 perl]# cat 27.pl
#!/usr/bin/env perl
use strict;
use warnings FATAL => 'all';
use 5.010;
sub greet {
state $last_person;
my $name=shift;
print "hi $name! ";
if (defined $last_person) {
print "$last_person is also here!\n";
} else {
print "you are the first one here!\n";
}
$last_person=$name;
}
sub greet1 {
state @names;
my $name=shift;
print "hi $name! ";
if (@names) {
print "i've seen: @names\n";
} else {
print "you are the first one here!\n";
}
push @names,$name
}
greet('fred');
greet('barney');
greet1('fred');
greet1('barney');
greet1('wilma');
greet1('betty');
[root@mysql1 perl]# ./27.pl
hi fred! you are the first one here!
hi barney! fred is also here!
hi fred! you are the first one here!
hi barney! i've seen: fred
hi wilma! i've seen: fred barney
hi betty! i've seen: fred barney wilma
#!/usr/bin/env perl
use strict;
use warnings FATAL => 'all';
use 5.010;
sub greet {
state $last_person;
my $name=shift;
print "hi $name! ";
if (defined $last_person) {
print "$last_person is also here!\n";
} else {
print "you are the first one here!\n";
}
$last_person=$name;
}
sub greet1 {
state @names;
my $name=shift;
print "hi $name! ";
if (@names) {
print "i've seen: @names\n";
} else {
print "you are the first one here!\n";
}
push @names,$name
}
greet('fred');
greet('barney');
greet1('fred');
greet1('barney');
greet1('wilma');
greet1('betty');
[root@mysql1 perl]# ./27.pl
hi fred! you are the first one here!
hi barney! fred is also here!
hi fred! you are the first one here!
hi barney! i've seen: fred
hi wilma! i've seen: fred barney
hi betty! i've seen: fred barney wilma
0 0
- 一个签到函数
- 一个简单的签到程序
- 签到
- 签到
- 签到....
- 签到
- 签到
- 签到
- 签到
- 签到
- 签到
- 签到
- 签到
- 签到
- 签到
- 签到
- 签到
- 签到
- 欢迎使用CSDN-markdown编辑器
- 网络通信框架Netty的TCP粘包/拆包解决方案
- 论Android Adapter notifyDataSetChanged与notifyDataSetInvalidated无效原因
- Android开发多线程时的注释事项
- 深度学习经验备忘录
- 一个签到函数
- iOS 应用文件夹地址获取
- CollapsingToolbarLayout用法详解(简洁易懂)
- Android 查看内存使用情况
- webrtc 源码分析
- 面试:实现AB两个数的值交换
- java对图片接收的实现
- Oracle中的to_char,to_date
- 开始