in reply to selective join

Hi monks, I have an array like this:

Are you really sure you have an array? It looks to me like what you have is a hash disguised as an array. That is,

my %record = ( Currency => 'USD', Asset => 'Equity', Country => 'USA' );
If that's the case, and if the key structure is similar across multiple such records, your code would be significantly clearer if you write something like
my $desc = join '_', @record{qw(Current Asset Country)};
(This assumes that your readers understand hash slices.)

Replies are listed 'Best First'.
Re: Re: selective join
by shenme (Priest) on Sep 24, 2003 at 17:17 UTC
    <movie_critic_mode>   Insightful!   Beautiful!   "I grinned broadly"   </movie_critic_mode>

    No, really, now that you point it out, it may _be_ a flattened hash AM's playing with.   And you point out a solution using hash slices because:

    • using keys %record would be wrong as you can't guarantee the order that the keys will be returned.
    • there may be other hash keys that he doesn't want to use