scalar forces the argument to be evaluated in scalar context, when it normally could be evaluated in list context.
This is usually very handy because when you evaluate any @array in scalar context, you get the length of the array. (Agreeably
scalar(@array) isn't the most intuitive way of getting the length of array, though. Most newbies seem to use
$#array-1 to get the array length... note, of course, that
length(@array) doesn't work!)