I'm trying to find out what you actually want to do with in your code.
open (OWO, "+>$owo") or die $!;
That opens your file for read/write, and then truncates it to be empty.
@ary = <OWO>;
The file is empty, so this makes @ary empty.
%hsh;
This should give you a warning, using a hash in void context. You do help yourself and use -w don't you?
undef @hsh {@ary};
Not quite sure what this is supposed to do. @ary is empty. So, you are undefining nothing at all. But, even if there was something to undefine, all it undefines is values, while the rest of the code uses keys. Hence, it seems to be pointless in stereo.
@list = keys %hsh;
I've a hard time figuring out the use of this statement. It only makes sense if %hsh was populated from code you didn't show.

I would write the code somewhat like this (untested, may contain errors):

open my $fh => "+< $owo" or die "Failed to open $owe: $!\n"; my %seen; my @unique = grep {!$seen {$_} ++} <$fh>; seek $fh, 0, 0 or die "Failed to seek $owe: $!\n"; print $fh @uniqe; truncate $fh => tell $fh or die "Failed to truncate $owe: $!\n"; close $fh;
But it's shorter to write:
system "sort -u $owe > $owe.tmp; mv $owe.tmp $owe";
But that of course requires Unix, or Windows with a decent developers kit installed.

-- Abigail


In reply to Re: Deleting Duplicates in an array by Abigail
in thread Deleting Duplicates in an array by blacksmith

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.