suppose have value 2 added matrix or range having [ 99 103 ] [ 267 271 ] what's method of doing ?
expected output:[ 101 105 ] [ 269 273 ].
i have fetch range ..here code.
enter code here $input= $argv[0]; open($file,"$input"); while($line=<$file>) { $ranges.=$line if($line=~m/\[/); print $ranges, if ($line=~m/----------------------------------------------------------------------/); }
i want add 2 matrix .thanks help
input file:
>13pk_a: starts 5 itndyrirsalptlkkvlteggscvlmshlgrpkgipmaqagkirstggvpgfqqkatl total number of repeat(s) = 2 length of repeat = 4 number of residues in repeat = 4 kkvl z0 [ 13 16 ] [ 44 47 ] ----------------------------------------------------------------
use strict; use warnings; $file = "path\\data.txt"; open (my $fh, "<", $file) or die "can't open file"; $number = 4; while ( $line = <$fh>){ if ( $line =~ /\[\s(\d*)\sto\s(\d*)\s]/){ $first_range = int($1); $first_range = $1 + $number; $second_range = int($2); $second_range = $2 + $number; print "\n[ $first_range $second_range ]"; } }
the regex store in $1
, $2
2 ranges.
$line =~ /\[\s(\d*)\sto\s(\d*)\s]/
base on input pattern [ number number ]
.
int($1);
this convert string integer.
$first_range = $1 + $number;
adds range number want ( hardcoed 4, my $number = 4
).
Comments
Post a Comment