Bill Ng wrote: > Okay, > > Here's what I've come up with: > ---------- > @list = ("aacs1110", "brbt4332", "rtxa4320", "aacs2000", > "brig5621", "brbt5220", "nbvc1111"); > @list = sort @list; > > foreach $item (@list) { > $itemPref = substr($item, 0, 4); > $itemVers = substr($item, 4); > $h{$itemPref} = $itemVers; } > > foreach $pref (keys %h) { > push (@finalList, $pref . $h{$pref}); } > ---------- > > Okay ... 8 lines of code (not counting empty lines) ... > anyone got anything else?
Here's one: $last{substr($_,0,4)}=$_ for @myArray; print join "\n", sort values %last; I'm sure we could reduce it to a one-liner with a modified Schwarzian Transform... - Mark. -- Mark Thomas Internet Systems Architect _______________________________________ BAE SYSTEMS Information Technology 2525 Network Place Herndon, VA 20171 USA _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs