Using qr (quote regex-wise) and allowing for the spaces in $line also works:
#!/usr/bin/perl -w use 5.018; # 1126143 my $line = ' [Category("notestrecord")]'; my $pattern = qr/[Category("notestrecord")]/; if($line =~ /\s*$pattern/) { print "Matched |$pattern| in |$line|"; # vbars to show spaces (& + lack of spaces) } else { print "No match!"; } =head OUTPUT: Matched |(?^u:[Category("notestrecord")])| in | [Category("note +strecord")]| =cut
In reply to Re: Problem with input strings that have "[]" brackets
by ww
in thread Problem with input strings that have "[]" brackets
by Laszlo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |