PERL: hash values as strings? + while () on @Array?

by =?iso-8859-1?Q?=22Alberto=2E=B7=2EVallini=22?= <vallinis(at)>

 Date:  Tue, 19 Sep 2000 20:17:13 +0200
 To:  hwg-techniques(at)
  todo: View Thread, Original
Some books declare that HASH VALUES in Perl are always considered as=20
STRINGS and never as numbers. None the less, trivial mathematical=20
operations such as:


can be carried out safely; a print method would reveal the $sum variable=20
being correctly updated to 2, and no warnings get displayed with the -w=20
command line parameter.
1) is it due to the fact that the "+" operator converts the hash value to a=
2) if so, is it true that hash values can never be handled safely as=20
numbers? Or is the allegation that hash values are always reproduced as=20
strings simply unaccurate?
3) does there exist a Perl function that forces a string to be evaluated as=
a number, like the javascript parseInt()?
4) does there exist a Perl function that can return me the type of the=20
value I'm handling in a scalar, such as the javascript typeof?
5) Last but not least: many a Perl book refer to examples of while loops=20
applied to an Array by providing conditions such as: while (@anArray) ; the=
assumption is the cycle will stop with the last element of the array. Now=20
either I'm quite dumb or there must be something wrong: any time I attempt=
such a looping, I enter an infinite loop. None the less books keep saying=20
it is feasable, right that way. I can quote by Laura Lemay (whose Perl book=
is fairly good, despite I would not reccomend her books on Html and surely=
not her book about javascript):
"You can ... supply an array variable anywhere a scalar value is expected-=
for example in any of these expressions: ... while (@arrayname) { }." Laura=
Lemay "teach yourself Perl in 21 days" pag 84.
Useless to say I never thought a programming language can be acquired in 21=
days, in fact here I am!
very much TIA!

Alberto.=B7.Vallini  - vallinis(at)
"when everything else fails, sleep"

Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA