我从以下代码中看到了结果,但我不完全理解在以下示例 中如何or
知道该做什么:sort
use Data::Dumper;
$animals{'man'}{'name'} = 'paul';
$animals{'man'}{'legs'} = 2;
$animals{'cheeta'}{'name'} = 'mike';
$animals{'cheeta'}{'legs'} = 3;
$animals{'zebra'}{'name'} = 'steve';
$animals{'zebra'}{'legs'} = 4;
$animals{'cat'}{'name'} = '';
$animals{'cat'}{'legs'} = 3;
$animals{'dog'}{'name'} = '';
$animals{'dog'}{'legs'} = 4;
$animals{'rat'}{'name'} = '';
$animals{'rat'}{'legs'} = 5;
@animals = sort {
$animals{$a}{'name'} cmp $animals{$b}{'name'}
or $animals{$a}{'legs'} <=> $animals{$b}{'legs'}
} keys %animals;
print Dumper(\@animals);