unix下执行perl
2015-07-14 14:13
260 查看
必须在某个文件夹下 。例如我的:
mnsdev13:scripts
进行vim编辑:
1 #!/usr/local/bin/perl5
2use strict;
3unless (@ARGV==2) {
4 die"Usage: perl $0 <input.fa> <out.len>\n";
5}
6my ($infile,$outfile) =
7
8
9
10@ARGV;
11
12
13open IN,$infile || die"error: can't open infile: $infile";
14 openOUT,">$outfile" || die$!;
15$/=">";<IN>;
16while ( my $seq = <IN>){
17 my $id = $1 if($seq =~ /^(\S+)/);
18 chomp $seq;
19 $seq =~ s/^.+?\n//;
20 $seq =~ s/\s//g;
21 my $len = length($seq);
22 print OUT "$id\t$len\n";
23 }
24$/="\n";
25close IN;
26close OUT;
~
~
~
~
~
~
~
~
~
~
0mnsdev13:scripts> ls
FASTA oekb_xml_download_url.pl pl
FASTA.pl oekb_xml_parse_load.pl
mnsdev13:scripts> ./FASTA.pl
ksh: ./FASTA.pl: cannot execute
mnsdev13:scripts> chmod +xFASTA.pl
mnsdev13:scripts> ./FASTA.pl
Usage: perl ./FASTA.pl<input.fa> <out.len>
13:scripts> perl5 FASTA.pl
Usage: perl FASTA.pl <input.fa> <out.len>
mnsdev13:scripts> ls -al
total 204
drwxr-xr-x 3 yoliu staff 9 Jul 14 00:52 ./
drwxr-xr-x 7 yoliu staff 9 Oct 14 2014 ../
drwxr-xr-x 6 yoliu staff 9 Oct 14 2014 .svn/
-rw-r--r-- 1 yoliu staff 457 Jul 14 00:48 FASTA
-rw-r--r-- 1 yoliu staff 44 Jul 14 00:52 FASTA.out
-rwxr-xr-x 1 yoliu staff 457 Jul 14 00:50 FASTA.pl*
-rw-r--r-- 1 yoliu staff 11846 Oct 14 2014 oekb_xml_download_url.pl
-rw-r--r-- 1 yoliu staff 81933 Oct 14 2014 oekb_xml_parse_load.pl
-rw-r--r-- 1 yoliu staff 0 Jul 14 00:49 pl
mnsdev13:scripts> ls -alFASTA.pl
-rwxr-xr-x 1yoliu staff 457 Jul14 00:50 FASTA.pl*
mnsdev13:scripts> ./FASTA.plFASTA FASTA.out
mnsdev13:scripts
进行vim编辑:
1 #!/usr/local/bin/perl5
2use strict;
3unless (@ARGV==2) {
4 die"Usage: perl $0 <input.fa> <out.len>\n";
5}
6my ($infile,$outfile) =
7
8
9
10@ARGV;
11
12
13open IN,$infile || die"error: can't open infile: $infile";
14 openOUT,">$outfile" || die$!;
15$/=">";<IN>;
16while ( my $seq = <IN>){
17 my $id = $1 if($seq =~ /^(\S+)/);
18 chomp $seq;
19 $seq =~ s/^.+?\n//;
20 $seq =~ s/\s//g;
21 my $len = length($seq);
22 print OUT "$id\t$len\n";
23 }
24$/="\n";
25close IN;
26close OUT;
~
~
~
~
~
~
~
~
~
~
0mnsdev13:scripts> ls
FASTA oekb_xml_download_url.pl pl
FASTA.pl oekb_xml_parse_load.pl
mnsdev13:scripts> ./FASTA.pl
ksh: ./FASTA.pl: cannot execute
mnsdev13:scripts> chmod +xFASTA.pl
mnsdev13:scripts> ./FASTA.pl
Usage: perl ./FASTA.pl<input.fa> <out.len>
13:scripts> perl5 FASTA.pl
Usage: perl FASTA.pl <input.fa> <out.len>
mnsdev13:scripts> ls -al
total 204
drwxr-xr-x 3 yoliu staff 9 Jul 14 00:52 ./
drwxr-xr-x 7 yoliu staff 9 Oct 14 2014 ../
drwxr-xr-x 6 yoliu staff 9 Oct 14 2014 .svn/
-rw-r--r-- 1 yoliu staff 457 Jul 14 00:48 FASTA
-rw-r--r-- 1 yoliu staff 44 Jul 14 00:52 FASTA.out
-rwxr-xr-x 1 yoliu staff 457 Jul 14 00:50 FASTA.pl*
-rw-r--r-- 1 yoliu staff 11846 Oct 14 2014 oekb_xml_download_url.pl
-rw-r--r-- 1 yoliu staff 81933 Oct 14 2014 oekb_xml_parse_load.pl
-rw-r--r-- 1 yoliu staff 0 Jul 14 00:49 pl
mnsdev13:scripts> ls -alFASTA.pl
-rwxr-xr-x 1yoliu staff 457 Jul14 00:50 FASTA.pl*
mnsdev13:scripts> ./FASTA.plFASTA FASTA.out
相关文章推荐
- C++中虚函数工作原理和(虚)继承类的内存占用大小计算
- Get the current user permission level on a list item with ecmascript
- numpy 保存数据
- Get the current user permission level on a list item with ecmascript 分类: Sharepoint 2015-07-14 14:13 7人阅读 评论(0) 收藏
- 正则如何匹配div下的所有<li>标签?
- CCBPM中的消息机制,CCIM服务端安装说明
- poj解题报告——1050
- Learning WCF Chapter1 Creating a New Service from Scratch
- 一步步教你上架iOS APP
- 【数据库 工具】
- Java继承与构造函数
- Redis作者:深度剖析Redis持久化
- 记一次CUPS打印问题
- icvPrecalculate
- Android仿微信(二)——仿微信联系人 首字母分类
- vector内存机制和性能分析
- RedHat Enterprise Linux 6.4使用Centos 6 的yum源
- 【Unity3D】【UGUI】UI Overview
- 猜算式
- jQuery EasyUI 在datagrid上使用combotree 进行多选