in reply to slurping into a substring'ed' array

That should work, but if you want a unique array then hashes will be the simplest way to go e.g
my @ids = qw/ A1 A2 A3 B5 B6 B7 C789 C790 /; my @letters = sort keys %{ { map { substr($_,0,1), undef } @ids } }; print "Found the following letters: @letters\n"; __output__ Found the following letters: A B C
See. Perl Idioms Explained - keys %{{map{$_=>1}@list}} for an explanation of the above technique for simply getting a unique list.
HTH

_________
broquaint

update: fixed bug as noted below by davido

Replies are listed 'Best First'.
Re: Re: slurping into a substring'ed' array
by davido (Cardinal) on Apr 26, 2004 at 15:21 UTC
    There's a hidden bug in that example. Try running it with a long list of unique alphas and you'll see what I mean. The problem is that in each map iteration you're only creating one item. In your hash assignment, one item is being assigned to the key, and the next to a value. The result is that some letters are being dropped.


    Dave