in reply to Sorting a subset

The first part, where you create @tempArray, is better written as:
my @tempArray = grep { /^A/ } @array;

So, your entire part can be rewritten to:

foreach my $ref ( sort { substr($a, 1) <=> substr($b, 1) } grep { /^A/ } @array ) { ... do whatever ... }

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.