my %hash;
my @array =(1,2,3,2,4,5,5);
@array = grep {++$hash{$_}<2}@array;
foreach my $item(@array){
print $item;
print "\n";
}
- 设置输入两个输入文件 并 定义一个可选的外部参数$str
my ($infile,$if_help,$str);
GetOptions(
|___"infile|i=s" => \$infile,
|___"if_help|h" => \$if_help,
|___"string|s:s" => \$str,
);
die help() if($if_help or not defined $infile);
my @files = split ",",$infile;
if (not $str){
|___$str = "####################################################";
|___say $str;
}
else{
|___say $str;
}
foreach (@files){
|___open F,$_ or die $!;
|___while (my $line = <F>){
|___|___chomp $line;
|___|___say $line;
}
|___close F;
}
sub help{
|___my $info="
program:
date:2019-7-31
name:zhangpanyu
usage perl $0
option:必填
|___|___infile|i 输入文件
option:选填
|___|___if_help|h 帮助文档
|___\n";
|___return $info;
}
网友评论