in reply to getting syntex error in pattern search
You need to insert semicolons between all your statements, including at the place that the syntax error occurs.
Please see perlintro and perlsyntax for detail.