It should be $i<$L and just 0 and not $0 ( $0 is the script name );

Wags ;) ps You should realize that the c/r remains with each line.

-----Original Message-----
From: rabs [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 12, 2002 17:52
To: [EMAIL PROTECTED]
Subject: Another simple program which doesnt work.



This newsgroup is great.  I am learning alot from just reading the post
here. I hope someone will be able to help with this query.

-------------

#!/usr/bin/perl-w
print "please enter a word then press enter\n";
@a= <STDIN>;
$L =@a;
for ($i=0; $i<=$L; $i++){
print $a[$i];
}
print "\n there are $L varibles in the hash";
print "\n why wont $a[$0] print out "


------------------



When I execute the code above, the first item in the array does is not
printed by the forloop. So if I enter the words press return " \n " after
each one.

Fish \n
have \n
underwater \n
weapons  \n

The program prints out

have
underwater
weapons

I can access the item $[$0]  outside the for loop. I am confused. Is it
something to do with newline characters?



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to