Affichage d'un tableau de hash

Le
kurtz le pirate
Bonjour,

J'ai mon AoH :

my @aoh_Attribute = (
{ id_Attribute => 25, id_Attribute_group => 4, position => 0, },
{ id_Attribute => 138, id_Attribute_group => 4, position => 12, },
{ id_Attribute => 126, id_Attribute_group => 4, position => 1, },
{ id_Attribute => 52, id_Attribute_group => 4, position => 11, },
{ id_Attribute => 51, id_Attribute_group => 4, position => 10, },
{ id_Attribute => 50, id_Attribute_group => 4, position => 9, },
{ id_Attribute => 49, id_Attribute_group => 4, position => 8, },
{ id_Attribute => 48, id_Attribute_group => 4, position => 7, },
{ id_Attribute => 26, id_Attribute_group => 4, position => 2, },
{ id_Attribute => 27, id_Attribute_group => 4, position => 3, },
{ id_Attribute => 29, id_Attribute_group => 4, position => 4, },
{ id_Attribute => 30, id_Attribute_group => 4, position => 5, },
{ id_Attribute => 247, id_Attribute_group => 4, position => 6, },
{ id_Attribute => 144, id_Attribute_group => 4, position => 13, },
);


Que j'affiche avec ce code trouvé sur perldsc.
for my $href ( @aoh_Attribute ) {
print "{ ";
for my $role ( keys %$href ) {
print "$role=$href->{$role}t";
}
print "}";
}
print "";


J'obtiens :
{ position=0 id_Attribute_group=4 id_Attribute% }
{ position id_Attribute_group=4 id_Attribute8 }
{ position=1 id_Attribute_group=4 id_Attribute6 }
{ position id_Attribute_group=4 id_AttributeR }
{ position id_Attribute_group=4 id_AttributeQ }
{ position=9 id_Attribute_group=4 id_AttributeP }
{ position=8 id_Attribute_group=4 id_AttributeI }
{ position=7 id_Attribute_group=4 id_AttributeH }
{ position=2 id_Attribute_group=4 id_Attribute& }
{ position=3 id_Attribute_group=4 id_Attribute' }
{ position=4 id_Attribute_group=4 id_Attribute) }
{ position=5 id_Attribute_group=4 id_Attribute0 }
{ position=6 id_Attribute_group=4 id_Attribute$7 }
{ position id_Attribute_group=4 id_Attribute4 }



C'est peut être normal, mais pourquoi l'ordre des clés n'est pas le même
que celui dans la déclaration du AoH ?


Merci

--
kurtz le pirate
compagnie de la banquise
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
Marc SCHAEFER
Le #26450859
kurtz le pirate
C'est peut être normal, mais pourquoi l'ordre des clés n'est pas le même
que celui dans la déclaration du AoH ?

Perl propose des tableaux de hâchage et non pas des tableaux associatifs
ordonnés.
L'ordre des clés est donc dépendant de l'implémentation et des
clés qui ont été insérées. Comme p.ex. dans un fichier DBM indexé
(cf tie).
Si un ordre est indispensable, alors énumérer par ordre d'un tableau
de clés, ou ajouter un attribut de numéro (order) et trier avec la version
à argument du sort:
foreach my $t (sort { $a <=> $b } keys %hash) {
}
en remplaçant $a <=> $b par exemple par
$hash{$a}->{'order'} <=> $hash{$b}->{'order'}
kurtz le pirate
Le #26450910
Le 06/11/2017 à 14:00, Marc SCHAEFER a écrit :
Perl propose des tableaux de hâchage et non pas des tableaux associatifs
ordonnés.
L'ordre des clés est donc dépendant de l'implémentation et des
clés qui ont été insérées. Comme p.ex. dans un fichier DBM indexé
(cf tie).

Donc c'est /normal/
Merci.

--
kurtz le pirate
compagnie de la banquise
Paul Gaborit
Le #26453444
À (at) Mon, 6 Nov 2017 12:30:43 +0100,
kurtz le pirate
J'ai mon AoH :

[...]>
Que j'affiche avec ce code trouvé sur perldsc.
for my $href ( @aoh_Attribute ) {
print "{ ";
for my $role ( keys %$href ) {
print "$role=$href->{$role}t";
}
print "}n";
}
print "nn";

[...]>
C'est peut être normal, mais pourquoi l'ordre des clés n'est pas le même
que celui dans la déclaration du AoH ?


C'est normal... et, en plus, avec les versions récentes de Perl, l'ordre
change à chaque exécution ! ;-)
--
Paul Gaborit - Perl en français -
clive Hors ligne
Le #26460869
Le lundi 06 Novembre 2017 à 12:30 par kurtz le pirate :
Bonjour,

J'ai mon AoH :

my @aoh_Attribute = (
{ id_Attribute => 25, id_Attribute_group => 4, position => 0, },
{ id_Attribute => 138, id_Attribute_group => 4, position => 12, },
{ id_Attribute => 126, id_Attribute_group => 4, position => 1, },
{ id_Attribute => 52, id_Attribute_group => 4, position => 11, },
{ id_Attribute => 51, id_Attribute_group => 4, position => 10, },
{ id_Attribute => 50, id_Attribute_group => 4, position => 9, },
{ id_Attribute => 49, id_Attribute_group => 4, position => 8, },
{ id_Attribute => 48, id_Attribute_group => 4, position => 7, },
{ id_Attribute => 26, id_Attribute_group => 4, position => 2, },
{ id_Attribute => 27, id_Attribute_group => 4, position => 3, },
{ id_Attribute => 29, id_Attribute_group => 4, position => 4, },
{ id_Attribute => 30, id_Attribute_group => 4, position => 5, },
{ id_Attribute => 247, id_Attribute_group => 4, position => 6, },
{ id_Attribute => 144, id_Attribute_group => 4, position => 13, },
);
Que j'affiche avec ce code trouvé sur perldsc.
for my $href ( @aoh_Attribute ) {
print "{ ";
for my $role ( keys %$href ) {
print "$role=$href->{$role}t";
}
print "}n";
}
print "nn";
J'obtiens :
{ position=0 id_Attribute_group=4 id_Attribute% }
{ position id_Attribute_group=4 id_Attribute8 }
{ position=1 id_Attribute_group=4 id_Attribute6 }
{ position id_Attribute_group=4 id_AttributeR }
{ position id_Attribute_group=4 id_AttributeQ }
{ position=9 id_Attribute_group=4 id_AttributeP }
{ position=8 id_Attribute_group=4 id_AttributeI }
{ position=7 id_Attribute_group=4 id_AttributeH }
{ position=2 id_Attribute_group=4 id_Attribute& }
{ position=3 id_Attribute_group=4 id_Attribute' }
{ position=4 id_Attribute_group=4 id_Attribute) }
{ position=5 id_Attribute_group=4 id_Attribute0 }
{ position=6 id_Attribute_group=4 id_Attribute$7 }
{ position id_Attribute_group=4 id_Attribute4 }
C'est peut être normal, mais pourquoi l'ordre des clés n'est pas
le même
que celui dans la déclaration du AoH ?
Merci

--
kurtz le pirate
compagnie de la banquise


We () use high quality equipment and materials to produce authentic and fake documents and Banknotes. These Banknotes are highly indistinguishable to touch, feel and naked eyes.This money carries individual serial and by pass security test
including UV-Light and iodine counterfeit pen maker.These notes can be used anywhere tested and approved. We do documents such as passport,ID Cards, Drivers license.All secret features of real passports are carefully duplicated for our Registered and unregistered documents.we are unique producer of quality false and Real documents.We offer only original high-quality Registered and unregistered passports, driver's licenses, ID cards, stamps, Visa, school Diplomas and other products for a number of countries like:USA, Australia, Belgium,Brazil, Canada, Italian,Finland, France, Germany, Israel, Mexico, Netherlands, South Africa,Spain, United Kingdom.
CONTACT OUR SUPPORTERS

General suppor:==========()

Contact e-mails:=====()

-IDs Scan-yes...
-HOLOGRAMS: IDENTICAL
-BARCODES: IDS SCAN
-UV: YES
FAKE IDS WITH FAST SHIPPING - EMAIL SUPPORT
We offer high quality counterfeit bills for the following currencies;
EUR - Euro
USD - US Dollar
GBP - British Pound
INR - Indian Rupee
AUD - Australian Dollar
CAD - Canadian Dollar
AED - Emirati Dirham
ZAR - Rand
CHF - Swiss Franc
CNY - Chinese Yuan Renminbi
MYR - Malaysian Ringgit
THB - Thai Baht

we are able to produce the following items;

REAL BRITISH PASSPORT.
REAL CANADIAN PASSPORT.
REAL FRENCH PASSPORT.
REAL AMERICAN PASSPORT.
REAL RUSSIAN PASSPORT.
REAL JAPANESSE PASSPORT.
REAL CHINESSE PASSPORT.

AND REAL PASSPORT FOR COUNTRIES IN THE EUROPEAN UNION.
REAL DRIVERS LICENSE,I.D CARDS,BIRTH CERTIFATES,DIPLOMATS,MARRIGE CERTIFICATES,AND VISAS.
REGISTERED AND UNREGISTERED BRITISH PASSPORT.
REGISTERED AND UNREGISTERED CANANIAN PASSPORT.
REGISTERED AND UNREGISTERED FRENCH PASSPORT.
REGISTERED AND UNREGISTERED AMERICAN PASSPORT.
REGISTERED AND UNREGISTERED RUSSSIAN PASSPORT.
REGISTERED AND UNREGISTERED JAPANESSE PASSPORT.
REGISTERED AND UNREGISTERED CHINESSE PASSPORT.

REGISTERED AND UNREGISTERED PASSPORTPASSPORT FOR COUNTRIES IN THE EUROPEAN UNION.
Buy Registered and unregistered USA(United States) passports,
Buy Registered and unregistered Australian passports,
Buy Registered and unregistered Belgium passports,
Buy Registered and unregistered Brazilian(Brazil) passports,
Buy Registered and unregistered Canadian(Canada) passports,
Buy Registered and unregistered Finnish(Finland) passports,
Buy Registered and unregistered French(France) passports,
Buy Registered and unregistered German(Germany) passports,
Buy Registered and unregistered Dutch(Netherland/Holland) passports,
Buy Registered and unregistered Israel passports,
Buy Registered and unregistered UK(United Kingdom) passports,
Buy Registered and unregistered Spanish(Spain) passports,
Buy Registered and unregistered Mexican(Mexico) passports,
Buy Registered and unregistered South African passports.
Buy Registered and unregistered Australian driver licenses,
Buy Registered and unregistered Canadian driver licenses,
Buy Registered and unregistered French(France) driver licenses,
Buy Registered and unregistered Dutch(Netherland/Holland) driving licenses,
Buy Registered and unregistered German(Germany) driving licenses,
Buy Registered and unregistered UK(United Kingdom) driving licenses,
Buy Registered and unregistered Diplomatic passports,
Buy Registered and unregistered USA(United States) passports,
Buy Registered and unregistered Australian passports,
Buy Registered and unregistered Belgium passports,
Buy Registered and unregistered Brazilian(Brazil) passports,
Buy Registered and unregistered Canadian(Canada) passports,
Buy Registered and unregistered Finnish(Finland) passports,
Buy Registered and unregistered French(France) passports,
Buy Registered and unregistered German(Germany) passports,
Buy Registered and unregistered Dutch(Netherland/Holland) passports,
Buy Registered and unregistered Israel passports,
Buy Registered and unregistered UK(United Kingdom) passports,
Buy Registered and unregistered Spanish(Spain) passports,
Buy Registered and unregistered Mexican(Mexico) passports,
Buy Registered and unregistered South African passports.
Buy Registered and unregistered Australian driver licenses,
Buy Registered and unregistered Canadian driver licenses,
Buy Registered and unregistered French(France) driver licenses,
Buy Registered and unregistered Dutch(Netherland/Holland) driving licenses,
Buy Registered and unregistered German(Germany) driving licenses,
Buy Registered and unregistered UK(United Kingdom) driving licenses,
Buy Registered and unregistered Diplomatic passports,
Registered and unregistered Camouflage passports,
Registered and unregistered passport Duplicates,
Registered and unregistered USA(united States) passports for sale,
Registered and unregistered Australian passports for sell,
Registered and unregistered Belgium passports for sell,
Registered and unregistered Brazilian(Brazil) passports for sell,
buy Camouflage passports,
express work permits

IELTS certificate,TOIC ETC
express canadian citizenship docu
verified id cards
passport registered
Canada Cards
United States Cards
Student Cards
International Cards
Private Cards
Adoption Certificates
Baptism Certificates
Birth Certificates
Death Certificates
Divorce Certificates
Marriage Certificates
Custom Certificates
High School Diplomas
G.E.D. Diplomas
Home School Diplomas
College Degrees
University Degrees
Trade Skill Certificates
Social Security
Validate SSN Number
Contact e-mails:=============== ()
General Support:=============== ()
Publicité
Poster une réponse
Anonyme