You seem to be doing everything correctly except for the "for" loop as you've
thought.  You have:

for($i=0; !!$b[$i]; $i++){
   print STDOUT $b[$i];
}

What you need instead is to say:
for($i=0; $i < @b; $i++){
   print $b[$i];
}

Remember, @b is evaluated in scalar context (@b = number of elements in array
b).  Remember also that perl arrays are not null-terminated lists where the
last element is "undef".  

Also, "print" prints to STDOUT by default, so, no need to mention that.  

Of course there is more than one way to do what you want to do, but I was just
correcting the way *you* wanted to do it :-)

        Aziz,,,



On Fri, 29 Jun 2001 22:19:06 -0600, Toni Janz said:

> I am just learning perl and have been doing some of the exercises in the
>  llama book.
>  
>  I was doing page exercise one from page 57 and I was pulling out my hair
>  as to why it was not working and then I did something experimental and
>  got it to work. But to be honest I have no idea why it works.
>  
>  I will attatch it to this email so that mayhap you can explain why it
>  does what it does.
>  
>  Note: the think that I added was the double bang '!!' 
>  I was previously using things like:
>  
>  for ($i=0; $b[$i] != undef; $i++)
>  {
>  print STDOUT $b[$i];
>  }
>  
>  and that seem logical but I was getting complaints such as..
>  "Argument "#stopped at 867\n" isn't numeric in ne at ./page57_1.pl line
>  9, <FILEIN> chunk 1544."
>  
>  anyhow hope you can enlighten me as to all this hullaballooo ;-)

Reply via email to