Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am using a small perl script function, where the following values exist:
$SEARCH - user input to search for
$RECORD - A line of data in a flat text file
$FIELD - Each Record line has delimited fields, fname, lname, add, phone, etc.I know this is a simple function, but can't seem to find the right syntax.
What "IF" statement do I use to find out if ($FNAME = "Michael";) contains ($SEARCH = "M";)
I don't care WHERE the string maybe found, just that it's in somewhere in $FNAME.
Can someone please show me the "IF" statement I would write for this ?
Thank YOU very MUCH in advance~!
- Michael McKenzie
Please email michael@therightdj.com

THANK YOU SO MUCH~!
Works like a charm. I knew it had something to do with /$SEARCH/ but couldn't get the right syntax.
Thanks again.
Michael

Next Search Question :0
Thanks for you help and I appreciate your response, I had just one more question.
If I search for a Full Name the values are added together with the "+" example:
$FULLNAME = "michael+mckenzie";
This will not match any of my data in $RECORD or $FIELD as everything is input without "+" signs. How do either add the "+" to my data on the fly as it searches, or REMOVE the "+" from my $SEARCH as it looks for the comparison ?
Thanks again~!
- Michael McKenzie

$FULLNAME =~ s/\+/\s/g;
That will substitute all occurences of + with a space. The g at the end means global, and will cause it to substitute all +'s, rather than just the first one it finds.

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

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