in reply to Re^3: General program and related problems
in thread General program and related problems
The output file is empty to be precise Cheers again!#!/usr/bin/perl -w use strict; my$line; my@fields; my@output; my$position; my%rs; open (FILE1, 'snp.txt') or die "can't open the file: $!"; open (FILE2,'chr22.txt') or die "can't open the file: $!"; open (FD, '>test.txt') or die "can't open the file: $!"; while ($line=<FILE2>) { $line=~/^(rs\d{5,})\b/; $position = tell( FILE2 ); if (defined $line) { $rs{$line}= $position; } } print %rs; while (defined ($line= <FILE1>)) { my@fields= split (/\s+/ ,$line); @output=grep /^rs\d{5,}\b/ ,@fields; } foreach (@output) { if (exists $rs{$_}) { seek(FILE2,$rs{$_},0); my $line= <FILE2>; print FD $line; } } close FILE1; close FILE2; close FD;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: General program and related problems
by jethro (Monsignor) on Aug 06, 2009 at 00:24 UTC | |
by micky744monk (Novice) on Aug 06, 2009 at 06:31 UTC | |
by jethro (Monsignor) on Aug 06, 2009 at 08:16 UTC | |
by micky744monk (Novice) on Aug 06, 2009 at 08:45 UTC | |
by jethro (Monsignor) on Aug 06, 2009 at 10:40 UTC | |
|