test1.txt
Expand|Select|Wrap|Line Numbers
- 53015910 53018079
- 53028477 53039398
- 53057449 53060200
- 53062918 53067636
- 53068725 53070903
- 53073104 53082405
- 53157340 53159848
- 53162114 53164278
- 53170778 53177010
- 53186077 53190880
1. I am adding the contents of test1 into a hashname
2. For each line in the second file, I am checking whether col 13 and col 35 lies between (key and value) of hashname
3. I am trying to interrupt once if the status is set to 1 so that I can stop avoiding the whole of hashname.
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl
- $st_status;
- $end_status;
- #adding contents into a hash
- $hashfile = 'test1.txt';
- open (LIST1, $hashfile) || die "File not found\n";
- while (<LIST1>) {
- chomp $_;
- @v = split(/\t/, $_);
- $hashname{$v[1]} = $v[2];
- }
- close(LIST1);
- #Search in the second file
- while(<>) {
- $st_status = 0;
- $end_status = 0;
- chomp $_;
- @cols=split(/\t/,$_);
- while (($key, $value) = each(%hashname)){
- if(($cols[12] >= $key) && ($cols[12] <= $value)) {
- $st_status = 1;
- last;
- }
- }
- while (($key, $value) = each(%hashname)){
- if((cols[34] >= $key) && (cols[34] <= $value)) {
- $end_status = 1;
- last;
- }
- }
- if (($st_status == 1 ) && ($end_status == 1)) {
- print "$_\n";
- } else { next; }
- }
- close FILE;