[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] looping while putting things into an array and thenusing it...



"Robert A. Decker" <comrade@umich.edu> writes:
>      if (@currentline[10] == $thisdateandtime) {
           ^make that an $

This should be "eq" for reasons explained below.

>         #set the variables that correspond to the selected web page. These
>
>         #will go into the fed web page.
>         $calltaker = @currentline[0];
                       ^ make this a $

>  So, you can see that I get throught the loop ok until '@currentline[10]
>== $thisdateandtime' (I also used 'eq' in place of '==' with the same
>results. I'm not exactly clear on when to use one or the other).

== compares numbers. eq compares strings. $a eq $b implies $a == $b, but
not vice versa.

A few examples: "Apples"   == "Oranges"
                "War"      == "Peace"
                "Freedom"  == "Slavery"
                "Ignorance"== "Strength"

I think you get the point.

>  I assume that '@currentline[10] == $thisdateandtime' evaluates as true
>because I don't go into my else statement.

Yes, but it falsely evaluates to true.

>  However, none of my variables that I try to assign before my 'last'
>statement that I use to try to break out of the loop are actually assigned.

Your main problem is that you're using @currentline[x] to denote array
elements. The type specifying character is always what you *want*, not what
you have, so you must write $currentline[x].

Matthias

-----
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "I'm set free to find a new illusion" -- Velvet Underground