You're not picky, you're right ! I had noticed the program created ash occurrences that pointes to nothing. But the information that a key exists - though it points to nothing - is different from the absence of a key.
Bour9 > -----Message d'origine----- > De : [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] De la > part de Brian Raven > Envoyé : mardi 10 juillet 2007 12:41 > À : [email protected] > Objet : RE: [RMX:#] Re: How to add to Associative Array > > Mostly being picky, but ... > > Bourgneuf Francois <> wrote: > > Your program works fine, you made a mistake in the final print. > > > > Here is a more "perlish" version > > > > $file = 'c:/temp/export/CONVERSION/test.txt'; # You can use > / instead > > of \, it works fine even under Windows > > open TEST, "$file" || die "Cant open file $file"; > > It would be better if you added the reason for failure, i.e. $!. > > > while(<TEST>) { > > chomp; > > You don't need two chomps and this one seems the most redundant. > > > if (/PLMEJob Master/../^$/) > > That should be 'if (/PLMEJob Master/../^\s*$/' in case the > line contains > white space characters (it will contain at least one if you remove the > above chomp). > > > { > > chomp; > > next if /PLMEJob Master/ || /^$/; > > my @a = split /=/; > > I would make the above two lines: > my @a = split /=/, $_, 2; > next unless @a > 1; > > It makes sure that @a contains no more than 2 entries, and it's a > simpler test for the line(s) to skip. > > > $info{$a[0]} = $a[1]; > > } > > } > > close(TEST); > > print "$_ => $info{$_}\n" foreach sort keys %info; > > Or perhaps Data::Dumper. > > > > > > > Big mistake : > > foreach(%info) > > { > > print "$_ => $info{$_}\n" > > } > > > > An associative array is an array indeed ! > > So when you print foreach %info, you print each key and each value. > > Of course it wont find any value for $info{value} > > Yup. > > HTH > > -- > Brian Raven > > ========================================= > Atos Euronext Market Solutions Disclaimer > ========================================= > > The information contained in this e-mail is confidential and > solely for the intended addressee(s). Unauthorised > reproduction, disclosure, modification, and/or distribution > of this email may be unlawful. > If you have received this email in error, please notify the > sender immediately and delete it from your system. The views > expressed in this message do not necessarily reflect those of > Atos Euronext Market Solutions. > > Atos Euronext Market Solutions Limited - Registered in > England & Wales with registration no. 3962327. Registered > office address at 25 Bank Street London E14 5NQ United Kingdom. > Atos Euronext Market Solutions SAS - Registered in France > with registration no. 425 100 294. Registered office address > at 6/8 Boulevard Haussmann 75009 Paris France. > > L'information contenue dans cet e-mail est confidentielle et > uniquement destinee a la (aux) personnes a laquelle > (auxquelle(s)) elle est adressee. Toute copie, publication ou > diffusion de cet email est interdite. Si cet e-mail vous > parvient par erreur, nous vous prions de bien vouloir > prevenir l'expediteur immediatement et d'effacer le e-mail et > annexes jointes de votre systeme. Le contenu de ce message > electronique ne represente pas necessairement la position ou > le point de vue d'Atos Euronext Market Solutions. > Atos Euronext Market Solutions Limited Société de droit > anglais, enregistrée au Royaume Uni sous le numéro 3962327, > dont le siège social se situe 25 Bank Street E14 5NQ Londres > Royaume Uni. > > Atos Euronext Market Solutions SAS, société par actions > simplifiée, enregistré au registre dui commerce et des > sociétés sous le numéro 425 100 294 RCS Paris et dont le > siège social se situe 6/8 Boulevard Haussmann 75009 Paris France. > ========================================= > > _______________________________________________ > ActivePerl mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
