Variable in Perl. Basically any singular item. A number, a character, or a string could be a scalar. It is indicated by a $.
Also in physics, a one dimensional measurement. For instance, speed is scalar because it only mentions rate, and not direction.

Perl command 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!)

Sca"lar (?), n. Math.

In the quaternion analysis, a quantity that has magnitude, but not direction; -- distinguished from a vector, which has both magnitude and direction.


© Webster 1913.

Log in or register to write something here or to contact authors.