string

Discussion in 'Programming/Scripts' started by deep_thought, Jan 28, 2007.

  1. deep_thought

    deep_thought New Member

    hello everyone. i am new to perl programming.
    so i wanted to ask you that after splitting up a string into an array of characters how do i check induvidually each character if it matches a set of characters...........

    for eg
    original string ------>FLLICEK
    i want to check each character if it is either T,D,L or F and if it is increment counter by 1

    F------> it is one of the characters T,D,L,F so increment counter to 1
    L-------> it is one of the characters T,D,L,F so increment counter to 1
    L-------->(2nd L) it is one of the characters T,D,L,F so increment counter to 1
    but i am not getting the method to do it .
    plz help me......
     
  2. deep_thought

    deep_thought New Member

    i tried to do it using the || operator

    Code:
    if($x=='T'||$x=='D'||$x=='L'||$x=='F'){
      $count+=1;
    }
    but it increments the counter for every character.
     
  3. Ben

    Ben Active Member Moderator

    maybe a debugoutput in the if that display $x's value helps you more...
    the if statements looks good...
     
  4. igongora

    igongora New Member

    I some times use phpmaker, and dreamweaver to make certain changes.
     

Share This Page