Thanks a lot guys ;) After few more modifications it worked... Now I have another problem and below is my code and how I want to get the output.I want to give serial number based on the value1 and value2.
Here is my code
#!/usr/bin/perl my %query_score; while ( <DATA> ) { chomp; ($value1,$value2,$Mark,$Name,$Country) = split(/\t/,$_); push( @{ $query_score{"$Name:$Country"}{position} },$value2); $query_score{"$Name:$Country"}{Mark} = $Mark; $query_score{"$Name:$Country"}{Start} = $value1; } foreach $key ( sort keys %query_score ) { ($Name,$Country) = split(/:/,$key); @positions = sort @{ $query_score{$key}{position} }; $Mark = $query_score{$key}{Mark}; $value1 = $query_score{$key}{Start}; $min = shift(@positions); $max = pop(@positions); print("$value1\t$value2\t$Mark\t$Country\t$min\t$max\n"); } __DATA__ 532 1148 a andrew2 Norway 1547 1573 b mathew3 US 2013 2190 c mathew US 2096 2158 d mathew US 2896 2980 e docker5 UK 3919 4622 f king4 Aus 4180 4353 g king Aus 6621 6758 h lover4 Canada 7475 7568 i nun8 Mexico 7645 7725 j brazil9 Brazil 7817 8008 k brazil9 Brazil 8172 8309 l brazil9 Brazil 8399 8536 m brazil9 Brazil
I am getting an OUTPUT like this:-
3919 4622 f king4 Aus 8536 8399 8536 m Brazil 7725 8536 4180 8536 g Aus 4353 6621 8536 h Canada 6758 7475 8536 i Mexico 7568
BUT I want my output to be like this:-
Value1 Value2 Mark Name Country SerialNo 532 1148 a andrew2 Norway start 1547 1573 b mathew3 US start 2013 2190 c mathew US between 2096 2158 d mathew US end 2896 2980 e docker5 UK start 3919 4622 f king4 Aus start 4180 4353 g king Aus start 6621 6758 h lover4 Canada start 7475 7568 i nun8 Mexico start 7645 7725 j brazil9 Brazil start 7817 8008 k brazil9 Brazil between 8172 8309 l brazil9 Brazil between 8399 8536 m brazil9 Brazil end
Thanks in advance

In reply to New Problem by crochunter
in thread 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.