How to concatenate variables in Perl

Viewed 62387

Is there a different way to concatenate variables in Perl?

I accidentally wrote the following line of code:

print "$linenumber is: \n" . $linenumber;

And that resulted in output like:

22 is:
22

I was expecting:

$linenumber is:
22

So then I wondered. It must be interpreting the $linenumber in the double quotes as a reference to the variable (how cool!).

What are the caveats to using this method and how does this work?

6 Answers
Related