I have a data file with following lines:

gtssmpar11/dmunit1/mt_dm_fifo_csr_flopped_out/u_gt_ram/wrdataR_reg_0_b +171_b174_b236_b242_qreg/d2 19.33 18.65 -0.67 (VIOLATED) gtssmpar11/dmunit1/mt_dm_fifo_csr_flopped_out/u_gt_ram/wrdataR_reg_0_b +186_b196_b210_b223_qreg/d2 15.09 11.70 -3.39 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b103_b104/d2 40.35 36.61 -3.74 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b105_b106/d1 11.06 8.77 -2.29 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b105_b106/d1 40.08 29.18 -10.90 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b119_b120/d2 11.37 8.34 -3.03 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b11_b12/d2 14.56 4.41 -10.15 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b11_b12/d2 45.82 27.47 -18.34 (VIOLATED)

And I need to get the unique value and the smallest one for the fourth column with corresponding 1st column.

Output should be:

gtssmpar11/dmunit1/mt_dm_fifo_csr_flopped_out/u_gt_ram/wrdataR_reg_0_b +171_b174_b236_b242_qreg/d2 19.33 18.65 -0.67 (VIOLATED) gtssmpar11/dmunit1/mt_dm_fifo_csr_flopped_out/u_gt_ram/wrdataR_reg_0_b +186_b196_b210_b223_qreg/d2 15.09 11.70 -3.39 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b103_b104/d2 40.35 36.61 -3.74 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b105_b106/d1 40.08 29.18 -10.90 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b119_b120/d2 11.37 8.34 -3.03 (VIOLATED) gtssmpar21/flunit1/flunitx1/fl_flex1/fl_mt_input_fifo/u_gt_ram/wrdataR +_dreg_b11_b12/d2 45.82

I tried using pattern matching to get the column 1 and column 4 in hash and then sort the hash. But its not working the way i want. Please help.


In reply to Sorting unique values in file using perl by PerlSavvy

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.