in reply to sorting with substrings

I'm no C++ or Java hacker but I'm pretty sure Perl's equivalent to those languages' struct is the hash (you might want to take a look at perldata). I'm not sure how useful they would be from the description of your problem though. I'm not sure whether the following is the most straightforward for you to understand at this point in your Perl skill-level, but this is how I might solve the problem (with the caveat that I'm taking your description of the problem very literally and that you have no control over the source data and your description of the sorting was complete):
my @data = qw( workstation_1_1 workstation_1_2 voiceserver_1_2 voiceserver_1_1 ); my @sorted = map { join('_', @{$_} ) # put the data back together again } sort { $a->[2] <=> $b->[2] # first sort by the final digit || $b->[0] cmp $a->[0] # then by the name, descending } map { # seperate the data out into seperate "fields" for easy # sorting (typically called a "Schwartzian Transform") [ split(/_/,$_) ] } @data; # the operation starts here (believe it or not)
If you're not familiar with map and sort, essentially, they act like "pipes" or "filters" that pass list data from the right side to the left, while giving you the option to perform some operation on each element of the list before you pass it on. So, it might help to start on the last line of the above example and follow the @data as it flows upwards into @sorted.

HTH
-- Brian