Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Sébastien Cottalorda
Salut,
Salut moi-même,
Voici mon problème: Je souhaiterai trier un hachage multidimentionnel selon l'ordre d'insertion. Voici le code qui ne marche pas:
#!/usr/bin/perl -w use strict; use Tie::IxHash; no strict 'subs'; my %hachage = (); my %hachage_complexe = (); die 'Tie Impossible' unless tie %hachage, 'Tie::IxHash'; die 'Tie complexe Impossible' unless tie %hachage_complexe, 'Tie::IxHash'; #======== Première Partie OK ===================== > $hachage{deux} = 2; $hachage{un} = 1; $hachage{cinq} = 5; $hachage{trois} = 3; $hachage{quatre} = 4; print "$_ => $hachage{$_}n" foreach keys %hachage; print "--------------------------------------n"; #======== Deuxième Partie PAS BON ================= Il suffisait d'ajouter:
die "Tie Impossible sur le hash de hash" unless tie $hachage_complexe{valeur},'Tie::IxHash';
La deuxième partie ne trie pas selon l'ordre d'insertion.
C'est bon maintenant!
Sébastien
Salut,
Salut moi-même,
Voici mon problème:
Je souhaiterai trier un hachage multidimentionnel selon l'ordre d'insertion.
Voici le code qui ne marche pas:
#!/usr/bin/perl -w
use strict;
use Tie::IxHash;
no strict 'subs';
my %hachage = ();
my %hachage_complexe = ();
die 'Tie Impossible' unless tie %hachage, 'Tie::IxHash';
die 'Tie complexe Impossible' unless tie %hachage_complexe, 'Tie::IxHash';
#======== Première Partie OK ===================== > $hachage{deux} = 2;
$hachage{un} = 1;
$hachage{cinq} = 5;
$hachage{trois} = 3;
$hachage{quatre} = 4;
print "$_ => $hachage{$_}n" foreach keys %hachage;
print "--------------------------------------n";
#======== Deuxième Partie PAS BON =================
Il suffisait d'ajouter:
die "Tie Impossible sur le hash de hash" unless tie
$hachage_complexe{valeur},'Tie::IxHash';
Voici mon problème: Je souhaiterai trier un hachage multidimentionnel selon l'ordre d'insertion. Voici le code qui ne marche pas:
#!/usr/bin/perl -w use strict; use Tie::IxHash; no strict 'subs'; my %hachage = (); my %hachage_complexe = (); die 'Tie Impossible' unless tie %hachage, 'Tie::IxHash'; die 'Tie complexe Impossible' unless tie %hachage_complexe, 'Tie::IxHash'; #======== Première Partie OK ===================== > $hachage{deux} = 2; $hachage{un} = 1; $hachage{cinq} = 5; $hachage{trois} = 3; $hachage{quatre} = 4; print "$_ => $hachage{$_}n" foreach keys %hachage; print "--------------------------------------n"; #======== Deuxième Partie PAS BON ================= Il suffisait d'ajouter:
die "Tie Impossible sur le hash de hash" unless tie $hachage_complexe{valeur},'Tie::IxHash';