Hi Drew,
How about writing a custom sort routine, based on the order you would be
using in the array, and returning that as a code ref? Sorting the hash
would be as simple as:
Common.pm:
sub getdata {
my $CR = sub { # generate code ref here };
my $HR = { 'sort_sub' => $CR, 123 => {foo=>bar, name=>'name', price=>'123'}};
return ($HR);
}
Otherstuff.pm:
my ($HR) = $self->getdata();
foreach (sort &{$HR->{'sort_sub'}} grep !/sort_sub/ keys %{$HR}) {
my $name = $HR->{$_}{name};
...
}
I'm assuming here that $AR's ordering may change based on a db select
or something similar; if it doesn't, then write it as a regular subroutine.
If sorting that way is really not an option, then just make $AR an array ref
as you had it, make it an element of $HR called 'sort', and change the foreach
Otherstuff.pm to read something like:
foreach (grep !/sort/ @{$HR->{'sort'}}) {
# la la la
}
darren
--
One man's "magic" is another man's engineering. "Supernatural" is a null word.
-- Robert Heinlein