Hi Monks, I was trying tag the record with maximum value. Here is my code so far:-
#!/usr/bin/perl use List::Util qw(min max); open(FH, $ARGV[0]) || die("Cannot open:$!"); while(<FH>) { if($_ =~ /\A(\S+)\t(\S+)\t(\S+)\t(\S+)\,(\S+)\,(\S+)/xmg) { #print "$1\t$2\t$3\t$4,$5,$6\n"; if(($5 == $5) && ($6 == $6)) { push @list, $4; $min = min @list; $max = max @list; if($4 == $max) { #print "$1\t$2\t$3\t$4,$5,$6\n"; print "$max\n"; } } } }
Here is the input file
62556 63635 y 1,andrew,JJ113954 63868 63897 h 1,morgan,JJ113955 68766 69005 j 2,morgan,JJ113955 81099 81630 y 1,flintoff,JJ113952 126185 126699 s 1,austin,JJ113956 135356 135449 3 1,peter,JJ113952 135588 136297 8 2,peter,JJ113952 158146 158367 i 3,peter,JJ113952 441474 441538 b 9,catherine,JJ029490 442666 442843 9 8,catherine,JJ029490 445778 445905 0 7,catherine,JJ029490 446059 446273 l 6,catherine,JJ029490 450319 450379 f 5,catherine,JJ029490
Here is the type of output I am trying to achieve :-
62556 63635 y single,andrew,JJ113954 63868 63897 h 1,morgan,JJ113955 68766 69005 j end,morgan,JJ113955 81099 81630 y single,flintoff,JJ113952 126185 126699 s single,austin,JJ113956 135356 135449 3 1,peter,JJ113952 135588 136297 8 2,peter,JJ113952 158146 158367 i end,peter,JJ113952 441474 441538 b end,catherine,JJ029490 442666 442843 9 8,catherine,JJ029490 445778 445905 0 7,catherine,JJ029490 446059 446273 l 6,catherine,JJ029490 450319 450379 f 5,catherine,JJ029490
Thanks in advance

In reply to Tagging the last elements by crochunter

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.