And if you use a string like a number, Perl turns it into a number and saves the result internally as a number, so that arithmetic is always fast. There's more magic to , but we'll ignore it for a while. But if you wrote cat file1 file2 file3 then cat would read from the three files in succession and concatenates their contents. Reading from a bunch of files specified on the command line is a common task, so Perl gives you a short cut for it. By now you've noticed that variables in Perl begin with dollar signs.
Scalar variables can hold one number or one string each.
If you're a C programmer, think of the times you've written half a page of C code to do exactly this task, and all the calls to strtok that you'll never have to make again if you use Perl. That makes error reporting convenient and easy in Perl. A hash is like an array, except that its indices are strings instead of numbers. There are too many useful uses of hashes to discuss them all here. But we'll see one example just so you can get the feel of real Perl programming.