in reply to Re: Extract line, matching more than one variable
in thread Extract line, matching more than one variable

There are two files, File 1 and File 2. Both have data in columns. Three variables from File 1, var1, var2 and var3 need to match a single line of file2 and that line needs to be extracted and appended in 'results file'. Wrote following code...could some one debug it for me. #!/usr/bin/perl -w #open file f-2 #print "Please type the filename of the data: "; $sasa_file= 'File1'; $pdbfile='File2'; # Remove the newline from the DNA filename open (MYXFILE,$sasa_file); open (PDBFILE, $pdbfile); while (<MYXFILE>){ chomp; @sa = split(/\t/,$_); #print "$sa[0] $sa1 $sa2\n"; #$res = substr $_, 0, 4; #$res_no = substr $_, 4, 5; #$atom =substr $_, 9, 3; while (<PDBFILE>){ chomp; $res = substr $_, 17, 3; $res_no = substr $_, 22, 4; $atom =substr $_, 13, 3; #print " $res $res_no $atom \n" ; # works fine if (( $sa[0]eq$res)&&($sa1==$res_no)&&($sa2 eq $atom)) { print "$_"; # does not print anything. } } } close MYXFILE; close PDBFILE;
  • Comment on Re^2: Extract line, matching more than one variable