Hi,

I'm in a need for some assistance. The thing is, I would need to write a counter that works in the same way as this one:

my %hash; my @array = qw(1 3 4 55 4 3 4 22 1 3 4 3 2 2 3 34); foreach (@array){ $hash{$_}++; }
and figure out which of the numbers in the array appear only one time, but i cannot use the built-in hash data structure.
so the result that i'm expecting would be
55,22,34 are the numbers that appear only once
Oh, yes and i have to stick to only basic conditionals and iterators, meaning no greping or mapping. however sorting is allowed. I was thinking of just sreating an array and then using indexes as hash keys but then a lot of positions would not be initialized(using space for nothing) and I would need to make 55 instead of 16 steps to get to my result.

Can anyone make a creative suggestion on how to do this in more effective and economic way ?

Thank you

baxy


In reply to How to hash without the hash- basic by baxy77bax

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.