unix下执行perl

来源:互联网 发布:网络诈骗特点有 编辑:程序博客网 时间:2024/05/17 23:58

必须在某个文件夹下  。例如我的:

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

 

 


0 0
原创粉丝点击