Hello KishKishore,
The variable $var1 contains the empty string, which matches any string (since any string, even the empty string itself, “contains” the empty string). That’s why the if block is executed.
15:58 >perl -wE "my $line = 'xyz'; my $var1 = ''; say 'Match' if $line + =~ /$var1/i;" Match 15:59 >
Hope that helps,
| Athanasius <°(((>< contra mundum | סתם עוד האקר של פרל, |
In reply to Re: Issue with matching regex
by Athanasius
in thread Issue with matching regex
by KishKishore
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |