Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I think Tom once helped me out on this syntax, but I forgot where I put it now... :(
I can successfully search a File Handle (MYDATA) for a search value ($SEARCH) in a while loop like the following:
while (){
if (/$SEARCH/){ ... do something}
}BUT HOW DO I search a STRING for a $SEARCH Value? I know it is something similar, but can't remember.
How do I search to see if "cow" ($SEARCH) is in the following string ($VALUE)?
$VALUE = "The cow jumped over the moon";
if ($VALUE = /$SEARCH/) { ... do something... }I know this is not the right syntax, but can someone point me in the right direction ? I am not worried about case sensitive issues, and I am not looking for an index function to tell me how many times it appears in the string, I just want a quick and easy TRUE/FALSE type situation if the "cow" can be found in the $VALUE string.
Thanks so much for your help in advance~!
- Michael

($string =~ /pattern/) ## true if the pattern is found somewhere in the string
so I think you want to use something like:if ("the cow jumped over the moon" =~ /cow/)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |