in reply to Alternative to smart match

I think you want a %seen hash

push @authority, $full unless $seen{$full}++;

if order doesn't matter you just built up %seen and do @authority = keys %seen at the end.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Alternative to smart match
by Bod (Parson) on Jan 22, 2022 at 11:33 UTC
    I think you want a %seen hash

    I think you right!

    Clearly I was overthinking it and missing the obvious...I don't even need the @authority array as I can build the output string directly from the hash keys

    my $auth_list = join '<br>', keys %seen;
    Thanks Rolf

      Great, your welcome.

      But please keep in mind that hashes are randomized in Perl, hence you can't rely on the order.

      If it's meant for display in HTML you might want to sort them first.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        ...please keep in mind that hashes are randomized in Perl...

        Yes, I do realise this but thanks for the reminder.

        In this application, the order doesn't matter. The data is for highways. The array is to store the highway authority(ies) for each route. Given that the length of the highway is very small compared to the geographic jurisdiction of the authority, very very few cross a border. So the vast majority of routes only have one authority. Ordering them doesn't matter for the odd one that does cross a border.