首页 > 代码库 > perl格式化模板
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, $mday, $hour, $min, $sec); print STDERR "$format_time $text\n"; }
perl格式化模板
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。