PDA

View Full Version : string


deep_thought
28th January 2007, 14:35
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......

deep_thought
30th January 2007, 16:13
i tried to do it using the || operator

if($x=='T'||$x=='D'||$x=='L'||$x=='F'){
$count+=1;
}

but it increments the counter for every character.

Ben
31st January 2007, 08:41
maybe a debugoutput in the if that display $x's value helps you more...
the if statements looks good...

igongora
14th April 2007, 18:12
I some times use phpmaker, and dreamweaver to make certain changes.