Re: Perl beginner question (ya know how beginners are!)

by "Marko Schilde" <webmaster(at)planetdiablo.de>

 Date:  Thu, 7 Sep 2000 21:33:21 +0200
 To:  "=?iso-8859-1?Q?Alberto.=B7.Vallini?=" <vallinis(at)yahoo.com>,
<hwg-languages(at)mail.hwg.org>
 References:  yahoo
  todo: View Thread, Original
You may have only specified three parameters, however in your case the
filename itself is the first parameter passed to your script.

HTH,

-M
----- Original Message -----
From: Alberto.�.Vallini <vallinis(at)yahoo.com>
To: <hwg-languages(at)mail.hwg.org>
Sent: Thursday, September 07, 2000 8:24 PM
Subject: Perl beginner question (ya know how beginners are!)


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