Dharshana Eswaran wrote:
I have a string which reads $str5 = " DL_FEM_ADJ1 = DL_FEM_LINE_FIRST, /* Keep the adjacent ones consecutive */"; Here i need to consider the variable and its value, ignoring the comment. I have a pattern which reads if($str5 =~ /\s*([A-Z_]+)\s=\s(\w+),*/) { print "$1 and $2\n"; } The above works, if the string is " DL_FEM_SCREEN_ADJ1 = DL_FEM_SCREEN_NO_SECOND_LINE_FIRST," (without the comments) I am unable to come up with a pattern which would ignore the comment and gives me the substrings which i want. I need to read DL_FEM_SCREEN_ADJ1 and DL_FEM_SCREEN_NO_SECOND_LINE_FIRST only. The input string can either occur with comments or without comments, since the input keeps changing. The input provided here is a sample input.
You don't need to match the parts of the string you don't need. In particular your trailing /,*/ has no effect, because it is not captured and the comma need not be there at all. I think this /(\w+)\s*=\s*(\w+)/ will do what you want. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/