hi, I got this program from one of forums: http://www.perlguru.com/gforum.cgi?post=32920 its something like this:
open(IN, "/path/outModified.pl") or die "$!"; while (my $line = <IN>) { chomp($line); my @array = (split (/\s+/, $line))[6, 7, 8]; # print "@array\n"; push @points, [ @array ]; } close(IN); print '@points : ', Dumper \@points; open my $out_file, '>', "/path/dist_modified.pl" or die "cannot open: +$!\n"; for my $i1 ( 0 .. $#points -1 ){ my ( $x1, $y1, $z1 ) = @{ $points[$i1] }; for my $i2 ( 1 .. $#points){ my ( $x2, $y2, $z2 ) = @{ $points[$i2] }; my [COLOR="Red"]$dist [/COLOR]= sqrt(($x2 - $x1)**2 + ($y2 - $y1)**2 + + ($z2 - $z1)**2); print $out_file "153L.pdb: the distance between CA $i1 and CA $i2 = $d +ist\n"; } } close $out_file or die "cannot close file: $!\n";
I have to modify the above code to fit my program. my doubt is, if i have to compare the $dist with another value in another file which has the data:
col1 col2 1 2.69 2 2.97032 3 3.25064 4 3.53096 5 3.81128 6 4.0916 7 4.37192 8 ....... so on..... . . 170 50.98 171 51.086....so on

can I match the value of $dist with the column 2(col2) with its approximate value and retrieve the corresponding column1(col1)value? I have to match the value of $dist to the second column value(maximum is upto 50. any value of $dist greater than 50 should stop at the value(170 50.98)and retireve the value 170 for $dist compared with 50.98 or to its nearest high value. I dont know how to write this in perl. Can you help...

To make it clear, if the value of $dist = 2.84, then the program should search for second row in the file 2 2.97032 and print only 2. that is the first column.it this possible. I think i have to use regular expressions?? or pattern matching??

pls help I am a beginner in perl. Thank you in advance

In reply to retrive data from another file by comparing the values by amshi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.