Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Alternative to smart match

by Bod (Parson)
on Jan 22, 2022 at 11:33 UTC ( [id://11140705]=note: print w/replies, xml ) Need Help??


in reply to Re: Alternative to smart match
in thread Alternative to smart match

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

Replies are listed 'Best First'.
Re^3: Alternative to smart match
by LanX (Saint) on Jan 22, 2022 at 11:47 UTC
    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.

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

        Is just one word longer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140705]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-03-28 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found