I seek your wisdom re why the 4th one-liner below returns "Matches!". The other 7 one-liners behave as I would have expected. I thought $a.$b would be the same as "$a$b" in contexts like this - it seems to be with last 'eq' tests. Was I mistaken? If I print them the output looks the same.
I added blank lines above purely for readability.$ perl -e '$a="A";$b="B";print "Matches!\n" if "$a$b" =~ /A/' Matches! $ perl -e '$a="A";$b="B";print "Matches!\n" if "$a$b" =~ /C/' $ perl -e '$a="A";$b="B";print "Matches!\n" if $a.$b =~ /A/' Matches! $ perl -e '$a="A";$b="B";print "Matches!\n" if $a.$b =~ /C/' Matches! # WHY??? $ perl -e '$a="A";$b="B";print "Matches!\n" if "$a$b" eq "AB"' Matches! $ perl -e '$a="A";$b="B";print "Matches!\n" if "$a$b" eq "C"' $ perl -e '$a="A";$b="B";print "Matches!\n" if $a.$b eq "AB"' Matches! $ perl -e '$a="A";$b="B";print "Matches!\n" if $a.$b eq "C"'
In reply to Why is $a.$b not = "$a$b"? by tel2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |