Yes I realise that. I was providing the example assuming that there was no specific order.
However you'll find that in your example sort isn't needed

...as hashes sort numerically automatically
%foo = ( 1 => 'foo', 5 => 'bar', 3 => 'bla' );
print join '|', keys %foo;
.....would print 1|3|5
Also your example won't work.
You'd need:
print join ("|", map { $def{$_} } keys %def) . "\n";
...which is kind of pointless as it will work the same as my example
Let's compare the output
my %def = (
0 => "myname", 1 => "myalias", 2 => "myemail", 3 => "myicq", 4 => "myphone",
5 => "myage", 6 => 'mylocal', 7 => "myconfirm", 8 => "mypay"
);
print join ("|", map { $def{$_} } keys %def);
print join ("|", map { $def{$_} } sort keys %def);
print join ("|", values %def);
........
myname|myalias|myemail|myicq|myphone|myage|mylocal|myconfirm|mypay
myname|myalias|myemail|myicq|myphone|myage|mylocal|myconfirm|mypay
myname|myalias|myemail|myicq|myphone|myage|mylocal|myconfirm|mypay
I win