in reply to How to hash without the hash- basic

No need for sort:

use warnings; use strict; use 5.010; package NotAHash; sub new { my ($class) = @_; return bless [], $class; } sub add { my ($self, $str) = @_; my $parent = $self; $parent = $parent->[substr $str, 0, 1, ''] //= [] while length $st +r; $parent->[10]++; } sub keys { my ($self) = @_; my @keys; for my $elementIdx (0 .. 9) { next if ! defined $elementIdx || ! defined $self->[$elementIdx +]; my $element = $self->[$elementIdx]; my @subKeys = NotAHash::keys ($element) if @$element; push @keys, "$elementIdx$_" for @subKeys; push @keys, $elementIdx if $element->[10]; } return @keys; } sub value { my ($self, $key) = @_; my $parent = $self; $parent = $parent->[substr $key, 0, 1, ''] //= [] while length $ke +y; return $parent->[10]; } package main; my @array = qw(1 3 4 55 4 3 4 22 1 3 4 3 2 2 3 34); my $notHash = NotAHash->new(); $notHash->add($_) for @array; my @singles; my @keys = $notHash->keys(); $notHash->value($_) == 1 && push @singles, $_ for $notHash->keys(); print join (', ', @singles), " are the numbers that appear only once\ +n";

Prints:

22, 34, 55 are the numbers that appear only once
True laziness is hard work