In your example:
#!/perl/ -w $pat=''; #thing to search for #line 3 while(){ print 'Enter the pattern'; chomp($pat =<stdin>); print 'enter the string:'; chomp($_ = <stdin>); #10 if($_ =- m/$pat/g) { print "true\n"; } else{print "false\n";} }
There is only one "pattern match operator" and that is: m/$pat/g. And the only problem with that is the use of the /g option, which in this case is superfluous.
Your problem is that the characters between $_ and m/$pat/g are not a valid perl operator.
In reply to Re: pattern match operator
by jwkrahn
in thread pattern match operator
by ostra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |