前端之家收集整理的这篇文章主要介绍了
perl格式化模板,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
#!/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("\n\tUnknown 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 $text\n";
}