[FoLUG] [perl - newbie] - scorrere un hash
samuele
enlargeyourlinux@yahoo.it
Mer 5 Gen 2005 15:54:05 CET
mi sono dato al perl o almeno ci sto provando. oggi mi trovavo a dover
scorrere
un hash con un ciclo foreach e mi accade una roba strana. Il codice č
questo:
foreach $key (sort keys %mod)
{
....
codice
....
}
premetto che dentro all'hash %mod al momento c'e' una sola chiave. ad
esempio dentro
%mod{pippo} c'e' pluto. Il codice fa quello che deve e key assume il
solo valore pippo.
Inizialmente avevo scritto il codice cosė:
foreach $key (%mod)
{
....
codice
....
}
e $key mi assumeva prima il valore pippo e poi anche pluto. e' normale?
Saluti
--
Samuele aka Sammo
< Powered by Gentoo-64bit - Athlon64 3200 >
If something looks like a duck, walks like a duck, and quacks like a
duck,what is it? The answer, of course, depends on whether or not the
name `duck' is a trademark! If it is, then the closest that something
can get, without permission of the owner of the trademark, is
`duck-like.'
si vis pacem para backup
"All parts should go together without forcing. You must remember that
the parts you are reassembling were disassembled by you. Therefore,
if you can't get them together again, there must be a reason. By all
means, do not use a hammer." IBM maintenance manual, 1975
Maggiori informazioni sulla lista
FoLUG