http://www.perlmonks.org?node_id=981329

slayedbylucifer has asked for the wisdom of the Perl Monks concerning the following question:

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:

ows301.dom.com, 10.157.118.42, oem300.dom.com, 10.157.124.58, omo300.dom.com, 10.157.124.58, pwd302.dom.com, 10.157.126.58, pwd302.dom.com, 10.157.126.58, pwd302.dom.com, 10.157.126.58, pwd302.dom.com, 10.157.126.58, pwd302.dom.com, 10.157.126.58,

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:

ows301.dom.com, 10.157.118.42, oem300.dom.com, 10.157.124.58, pwd302.dom.com, 10.157.126.58,

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

-Thanks.