Is there a different way to concatenate variables in Perl?
I accidentally wrote the following line of code:
print \"$linenumber is: \\n\" . $linenumb
When formulating this response, I found this webpage which explains the following information:
###################################################
#Note that when you have double quoted strings, you don't always need to concatenate. Observe this sample:
#!/usr/bin/perl
$a='Big ';
$b='Macs';
print 'I like to eat ' . $a . $b;
#This prints out:
# I like to eat Big Macs
###################################################
#If we had used double quotes, we could have accomplished the same thing like this:
#!/usr/bin/perl
$a='Big ';
$b='Macs';
print "I like to eat $a $b";
#Printing this:
# I like to eat Big Macs
#without having to use the concatenating operator (.).
###################################################
#Remember that single quotes do not interpret, so had you tried that method with single quotes, like this:
#!/usr/bin/perl
$a='Big ';
$b='Macs';
print 'I like to eat $a $b';
#Your result would have been:
# I like to eat $a $b
#Which don't taste anywhere near as good.
I thought this would be helpful to the community so I'm asking this and answering my own question. Other helpful answers are more than welcome!