perl格式化模板
发布时间:2020-12-15 23:50:48 所属栏目:大数据 来源:网络整理
导读:#!/usr/bin/env perluse warnings;use strict;use Getopt::Long;use FindBin qw($Bin);use File::Basename qw(basename);use File::Spec::Functions qw(rel2abs);##### main program #####my $mainPL = basename($0);my $ysbin = "$Bin/ysbin";main;exit;sub
#!/usr/bin/env perl
use warnings;
use strict;
use Getopt::Long;
use FindBin qw($Bin);
use File::Basename qw(basename);
use File::Spec::Functions qw(rel2abs);
##### main program #####
my $mainPL = basename($0);
my $ysbin = "$Bin/ysbin";
&main;
exit;
sub main
{
&usage if(@ARGV < 1);
my $command = shift(@ARGV);
my %func =
(
"venn" => &;venn,);
if(!defined($func{$command}))
{
warn("ntUnknown command: "$command"n");
&usage;
}
&{$func{$command}};
}
sub usage
{
die(qq/
Usage: $mainPL <command> [options]
Command:
venn draw venn pics and get venn matrix of samples.
n/);
}
##### sub program #####
sub venn
{
my $pl = "perl $ysbin/venn.pl";
my $help;
GetOptions(
"help|h" => $help,);
die `$pl 2>&1` if($help);
die(qq/
Usage: $mainPL venn <files> <labels>
Notes:
1. Need R and VennDiagram package of R
2. <files> means a,b,...(2~5 files); <labels> means x,y,...(2~5 labels)
Options:
-help|-h see the detail help information about venn
n/) if(@ARGV != 2);
&runSH("$pl -f $ARGV[0] -l $ARGV[1]");
}
sub runSH
{
my ($sh) = @_;
&showTime($sh);
`$sh`;
&showTime("Task is completed~");
}
sub showTime
{
my ($text) = @_;
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
my $format_time = sprintf("[%d-%.2d-%.2d %.2d:%.2d:%.2d]",$year+1900,$mon+1,$sec);
print STDERR "$format_time $textn";
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
