2019-07-30perl小知识总结

2019-07-31  本文已影响0人  Bio小盼
my %hash;
my @array =(1,2,3,2,4,5,5);
@array = grep {++$hash{$_}<2}@array;
foreach my $item(@array){
print $item;
print "\n";
} 
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;
} 
上一篇下一篇

猜你喜欢

热点阅读