будьте введены, проверьте условия

Что-либо как это должно быть в странице справочника

В особенности:

Numperm     Number of frames used for files (in 4 KB pages).  
Process     Percentage of real memory used by process segments.  
System      Percentage of real memory used by system segments.  
Free        Percentage of real memory that is free.

2
06.07.2012, 01:13
1 ответ

Я предположил, что извлеченные строки региона следуют за строками CDS для каждого выравнивания.

Скопируйте этот код в script.pl:

use strict;
use warnings;

my $input = 1;
my @field = ('CDS','extracted region');
my (%data);
my (%counter);
&zero;

while ( <> ) { 

    ## Omit header.
    next if $. == 1;
    next if $. == 2;

    ## Remove last '\n'.
    chomp;

    ## Split line in tabs.
    my @f = split /\t/;

    ## Is loop over?
    if ( $f[2] =~ /$field[0]/ && $counter{$field[1]} > 1 )
    {
    &comparing;
    &zero;
    }

    ## Count number of $field[0] and $field[1] line
    $counter{$f[2]}++;

    ## Storing data
    @{$data{$f[2]}[$counter{$f[2]}]} = @f;
}

&comparing;

sub zero {
    $data{$field[0]} = [];
    $data{$field[1]} = [];
    $counter{$field[0]} = 0;
    $counter{$field[1]} = 0;
}

sub comparing {
    ## Is same line ($field[0] and $field[1])? if ( $input == 1 )
    if ( $counter{$field[0]} ==  $counter{$field[1]} || $input == 2 )
    {
    &recover;
    &stamp;
    }
}

sub recover {
    my $pos = &input2(0,0)  if ( $input == 2 );
    for my $i ( 1 .. $#{ $data{$field[0]} } ) {
    &input1($i) if ( $input == 1 );
    &input2($i,$pos) if ( $input == 2 );
    }
}

sub input1 {
    #;Extracted interval="376914 -> 377067"
    $data{$field[1]}[$_[0]][8] =~ m/;Extracted interval="(\d+) /;
    $data{$field[0]}[$_[0]][3] = $1;
    $data{$field[1]}[$_[0]][8] =~ m/;Extracted interval="\d+ -> (\d+)"/;
    $data{$field[0]}[$_[0]][4] = $1;
}

sub input2 {
    if ( $_[0] == 0 )
    {
    #;Extracted interval="2010140 <- 2024072"
    $data{$field[1]}[1][8] =~ m/;Extracted interval="(\d+) /;
    $1;
    }
    else
    {
    $data{$field[0]}[$_[0]][3] = $_[1] + $data{$field[0]}[$_[0]][3];
    $data{$field[0]}[$_[0]][4] = $_[1] + $data{$field[0]}[$_[0]][4];
    }
}

sub stamp {
    for my $i ( 1 .. $#{ $data{$field[0]} } ) {
    for my $j ( 0 .. $#{ $data{$field[0]}[$i] } ) {
        print "$data{$field[0]}[$i][$j]\t";
    }
    print "\n";
    }
}

Вы могли запустить скрипт жемчуга с input1.txt:

perl script.pl input1.txt > output1.txt

если Вы изменяете строку:

my $input = 1;

с

my $input = 2;

Вы могли запустить скрипт жемчуга с input2.txt:

perl script.pl input2.txt > output2.txt

Сценарий Perl мог также получать два аргумента: входной файл и тип [12].

Править

В https://stackoverflow.com/questions/1730333/how-do-i-use-getoptions-to-get-the-default-argument существуют некоторые методы, собирающиеся получать аргументы.

Если Вы изменяете строку:

my $input = 1;

с

my $input = 1;
$input = $ARGV[1] if defined $ARGV[1];

Вы могли запустить скрипт жемчуга с input1.txt:

perl script.pl input1.txt > output1.txt

или

perl script.pl input1.txt 1 > output1.txt

и Вы могли запустить скрипт жемчуга с input2.txt:

perl script.pl input2.txt 2 > output2.txt
1
27.01.2020, 22:23

Теги

Похожие вопросы