Deal with documents by Perl

#!/usr/bin/perl -w
use strict;
use warnings;

my $usage=<<USAGE;
Usage:
    perl $0 filename_with_clinical.txt /path/to/file
USAGE
if(@ARGV==0){die $usage};

my $file1=$ARGV[0];
my $file2=$ARGV[1];
my @filename;

opendir(DIR,$file2) || die $!;
@filename=readdir(DIR);
splice(@filename,0,2);
close(DIR);

my $tcgaid;

open(RF,$file1) || die $!;
while(my $line=<RF>){
    chomp($line);
    my @arr=split(/\t/,$line);
    if(($. % 2) == 0){
        $tcgaid="$arr[2]-T2-$arr[3]";
    }else{
        $tcgaid="$arr[2]-T1-$arr[3]";
    }
    for my $i (0..$#filename){
        if($arr[0] eq $filename[$i]){
            rename ("$file2/$filename[$i]","$file2/$tcgaid.bw");
        }
    }
}
close(RF);
此条目发表在Perl分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Protected with IP Blacklist CloudIP Blacklist Cloud