CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
need perl matching - very urgent

 



abcindiaxyz
New User

Jan 20, 2008, 10:48 PM

Post #1 of 2 (3041 views)
need perl matching - very urgent Can't Post

Hi All,

I have some Languages with braces in my table

Note: It has all the languages the below are the examples of the languages that has braces

Ex: Altaic [other],Baltic [other],Bantu (other),Batak (Indonesia),Berber (other)


which comes from database, if user selects any of these Languages the match case mathes the value with all the Languages in database and
hilights the selected one as "selected" in list box.

the code which i'm using is

@olanglist[$i] is the array of all languages
@otherlang is the selected language

$i = 0;
while (@olanglist[$i]) {
foreach(@otherlang){
$olang = "<option>$_";
$_ = $olang;
if (m/@olanglist[$i]/){
@olanglist[$i] =~ s/\<option\>/<option selected>/o;
}
}
$i++;
}


but not the match case is not matching the values that has Braces ,rest all are fine ,

can any one pelse suggest me how to do it ?


KevinR
Veteran


Jan 20, 2008, 11:24 PM

Post #2 of 2 (3038 views)
Re: [abcindiaxyz] need perl matching - very urgent [In reply to] Can't Post

instead of:


Code
 if (m/@olanglist[$i]/){


try:


Code
 if (m/\Q$olanglist[$i]\E/){


using \Q..\E escapes the meta characters in the search pattern. I'm not sure this will actually solve your problem, but it has to be done anyway.

Also, you should not use @array[n] notation to access the individual elements of an array, use $array[n], which is the proper context.

Please do not use"urgent" in future posts. Your question will be answered or not answered like all other questions.
-------------------------------------------------


(This post was edited by KevinR on Jan 20, 2008, 11:26 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives