Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I am fetching two columns from oracle DB using the DBD::Oracle module. this is my code whihc Actually fetches the output:

my $sth = $dbh->prepare($query); $sth->execute(); while ( my $row_ref = $sth->fetchrow_arrayref ) { my $vm = $row_ref->[0]; my @nfs = split (/:/, $row_ref->[2]); my $filer = $nfs[0]; print "$vm, $filer, \n"; }

I have omitted rest of the code but above while loop should get you the idea what I am trying to do. "$query" value was given to me by the Oracle DBA and it is fairly complicated as it does quite a few comparisons. BTW, i dont udnertand how that query is wirtten. Anyway, it fetcehs the information that I need.

The problem is, the output of above "while" loop gives me few duplicate entries as below:,,,,,,,,,,,,,,,,

Pelase note that the Query statement has the "unique" function running. But after I run the "split" command in while loop, I get above few duplicate entries.

So, How to sort these entries and make them unique. I mean above, above duplicate entries should look like below:,,,,,,

please guide me on a technique which can be used in above "while" Loop. In bash, it is fairly simple to run ...| sort | uniq . but I could not find a way in perl to do the same


In reply to Uniq and sort in perl by slayedbylucifer

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (3)
    As of 2018-05-27 06:08 GMT
    Find Nodes?
      Voting Booth?