Dear all.. I'm very new to perl script, I'm able to read input from a file, and split them into column. The problem is I've no idea how compare line 1 and line 2 variable. For example :
scf7180000168636 1 40919 40986 Pseudo TGT 0 + 0 25.93 scf7180000168636 2 28112 28037 Asn GTT 0 + 0 86.57 scf7180000168636 3 27372 27295 Ile GAT 0 + 0 54.85 scf7180000168636 4 27287 27213 Gly TCC 0 + 0 45.71 scf7180000168636 5 839 753 Leu CAG 0 + 0 72.78 scf7180000168667 1 1672 1598 Arg CCT 0 + 0 72.32 scf7180000168683 1 509 584 Met CAT 0 + 0 90.27 scf7180000168700 1 1405 1329 Val GAC 0 + 0 91.08 scf7180000168709 1 11151 11067 Leu CAA 0 + 0 75.09 scf7180000168716 1 481 406 Thr TGT 0 + 0 81.30 scf7180000168723 1 999 923 Val GAC 0 + 0 90.22 scf7180000168736 1 813 888 Val TAC 0 + 0 93.03 scf7180000168736 2 912 988 Asp GTC 0 + 0 95.34 scf7180000168827 1 5375 5451 Val GAC 0 + 0 91.08
I know how to compare the value for each of the variable horizontally, but what if i want to compare something from line 1 and line 2? My current code :
#!/usr/local/bin/perl -w #tRANSCAN-SE_extract die "usage: $0 tRNASCAN-SE.list\n" unless @ARGV ==1; while (<>) { my ($seq, $tRNA_no, $p1, $p2, $amino, $anticodon, $stat1, $stat2, +$percent) = split; $beg = $p1 if $p2 > $p1; $beg = $p2 if $p2 < $p1; $end = $p1 if $p1 > $p2; $end = $p2 if $p1 < $p2; system ("extractseq -sequence=$seq.seq -auto -stdout -separate + -reg=$beg..$end"); }
I can print out line by line. By how can I print out only $p1 and $p2 if the $seq is the same? Something like "$seq $beg..$end,$beg..$end..." ? Thanks in advanced for helping me...tq!

In reply to Perl Multiline Regex by joomanji

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.