Roiy Zysman wrote: > > Hi All, Hello,
> How can i get the hash reference when i use a function to sort that hash. > e.g. i want to sort the hash according to is values > I can do something like this > sort {$hash{$a} cmp $hash{$b}} (keys %hash); > but i want to sort it by using a call to a function , something like this > foreach my $item ( sort $sort_func keys %$hash){ > how do i know what is the name of the hash inside the scope of the sort_func ??? > > something like that maybe ??? > sub sort_hash_by_year_month(){ > $_{$a} <=> $_{$b}; > } No, you are going to have to use the actual hash name (or a reference to the hash) because the sub that sort uses only accepts the two values it is comparing. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]