Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Probleme avec un tableau associatif

1 réponse
Avatar
Acide
Salut voila un bout de code qui me pose quelques soucis. Lorsque
je charge mon tableaux associatif avec comme valeur un tableau,
lorsque je sors de la fonction, ma valeur n'a pas été pris en compte.
Ca sent clairement un probleme d'allocation mémoire lié à la visiblité
de la fonction.

Si quelqu'un as une idée merci.


my %assoc_host = (
"hrSystemNumUsers" => "",
"hrSystemProcesses" => "",
"hrSystemMaxProcesses" => "",
"hrMemorySize" => "",
"hrStorageIndex" => ["pouet", "tata"],
"hrStorageDescr" => ["pouet", "tata"]
);

....
#ajout dans le tableau assoc
sub parse_host{
....
if ($i =~ /^hrStorageDescr/){
print "Add to array for $i $datav\n";
push @{ $assoc_host{$i} }, $datav;
}
....
}

sub mysql_save(){
print "Mysql dump\n";

print "---- System info ------\n";
foreach my $i (keys(%assoc_mib)){
print $i . " = " . $assoc_mib{$i} . "\n";
}

print "---- Ressources infos ------\n";
foreach my $i (keys(%assoc_host)){
if ($i =~ /^hrStorageDescr/){
print "Size = " . @{ $assoc_mib{$i}} . "\n";
# line 82
}
else{
print $i . " = " . $assoc_host{$i} . "\n";
}
}
}


sub open_file(){
....
parse_host($line);
....
}

open_file();
mysql_save();

#fin

root@trunc>./all.pl
Add to array for hrStorageDescr /
Add to array for hrStorageDescr /usr
Add to array for hrStorageDescr /export/data
Add to array for hrStorageDescr /export/mp3
Add to array for hrStorageDescr Real Memory
Add to array for hrStorageDescr Swap Space
Add to array for hrStorageDescr Memory Buffers
Mysql dump
---- System info ------
sysLocation = EPITA-Student, Paris, France
sysDescr = Linux trunc 2.4.20-gentoo-r5 #7 Mon Feb 16 22:36:15 CET 2037 i686
sysUpTime = (1379986) 3:49:59.86
sysName = trunc
sysContact = acide <acide@bombal.org>
---- Ressources infos ------
hrSystemNumUsers = 1
hrSystemProcesses = 44
hrSystemMaxProcesses = 0
hrMemorySize = 255192 KBytes
Can't use an undefined value as an ARRAY reference at ./all.pl line 82.

#fin

et la c'est le drame :(

Acide.

1 réponse

Avatar
Acide
"Acide" wrote in message
news:bpdbfg$2liu$

euh, laissé tomber j'ai trouvé. Evidemment les lois de murphy....

Acide.