On Jan 13, rabs said:

>#!/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];
>}

Your loop should be

  for ($i = 0; $i < $L; $i++) { ... }

Notice <= should be <.  It should also be noted that the idiomatic way of
looping over an array is like so:

  for (@a) {
    # do something with $_
  }

So your code could be:

  @a = <STDIN>;
  for (@a) { print }

And, since we're on the subject, you could rewrite those as:

  while (<STDIN>) { print }

>print "\n there are $L varibles in the hash";
>print "\n why wont $a[$0] print out "

The data structure is not a hash, it is an array.  And $0 is the variable
holding your program's name.  I believe you meant $a[0].

>The program prints out
>
>have
>underwater
>weapons

I bet you're on a windows machine, and windows has a notorious habit of
"eating up" the first line of output. :(

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


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

Reply via email to