Perl beginner question (ya know how beginners are!)

by "Alberto.�.Vallini" <vallinis(at)yahoo.com>

 Date:  Thu, 7 Sep 2000 11:24:16 -0700 (PDT)
 To:  hwg-languages(at)mail.hwg.org
  todo: View Thread, Original
Perl beginner dilemma: I have the following code: when
printing the hash, it assigns to the first key no
contents: how happens? I was expecting to get assigned
values ONLY to actual inputs provided at the STDIN!
Where does the first empty key comes out from, thus
determining an amount of ***4*** hash values printed,
since I only provided ***3*** inputs at the prompt?

Code:
%example=();
$assign="w";
while ($assign ne "") {
chomp($assign=<STDIN>);
$example{$assign}="this is a value assigned on the fly
to KEY: $assign";
}


foreach $key (keys %example) {
print($key."=".$example{$key}."\n");
# printing instruction above gives the following
output, with input: one.two, three:
# =this is a value assigned on the fly to KEY:
# one=this is a value assigned on the fly to KEY: one
# two=this is a value assigned on the fly to KEY: two
# three=this is a value assigned on the fly to KEY:
three

# QUESTION: why we get a first key with unassigned
contents? ie: " =this"
}

Thank you for any possible help (in plain simple words
eheh)!


=====
Alberto.�.Vallini - vallinis(at)yahoo.com
http://www.geocities.com/earthalliances/
"when everything else fails, sleep"

__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

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