Kasi ramanathen wrote: > hi friends, > > i have a problem in work i want to use a variable in the place of > pattern to be matched, but i don't know how? but some great brain > some ware in the world will be knowing it. > > hear i explain the program, when i use the patter i get the right > output when i store it in variable t and use it no output comes help > me? > > open (H, "<st.htm"); > @a=<H>; > $ln=join('',@a); > $t="<DIV > class=link><A\s*?href=\"(.*?)\"><IMG[\s\S]*?border=0>([\S\s]*?)<\/A><\/D IV>[\s\S]*?15px\">(\w[\s\S]*?)<\/DIV>"; > while($ln=~m/$t/g)
Kasi. A quick reply, I'm afraid. Your pattern match will work if you quote your regex with qr//. Also You'd be better off using the /x modifier on your regex so that you can lay it out better, something like this: $t = qr/ <DIV\sclass=link> <A\s*?href=\"(.*?)\"> <IMG[\s\S]*?border=0> ([\S\s]*?) <\/A> <\/DIV> [\s\S]*?15px\"> (\w[\s\S]*?) <\/DIV> /x; where whitespace may be used without affecting the pattern, although any spaces that must be matched have to be put in explicitly. But I'm a little worried about some of the stuff in your regex. For instance [\s\S] is a character class containing all whitespace characters and all non-whitespace characters, so it's the same as '.'. Also you seem to be searching for two closing </DIV> tags but only one opening one. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]