First of all, please wrap your code in <code> ... </code> tags, so that it's easier to read.
Secondly, I think what you're looking for is to "escape" the brackets [ ... ] within your regular expression. So perhaps you want something like the following ...?
my $tempreg = $p->get_token()->raw; if ($tempreg =~ /\[192\.168\.242\.2\]/) { print "finally a match\n"; }
You can read more about regular expressions in perlrequick, perlretut, or perlre, where you'll see that the bracket characters [ ... ] are "metacharacters" with special meaning (specifically, they delimit "character classes"), so you have to put backslashes in front of any to search for them like other, non-special characters. The same thing is also true of periods ".", which when unescaped, match any character except newline, and must therefore also be escaped with "\".
In reply to Re: regexp problem, square parentheses ("brackets")
by liverpole
in thread regexp problem, square paranthesis
by alex452
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |