More about context

Many different functions and operators behave differently depending on whether they're called in scalar context or list context. Each one will be noted in its documentation, either in the Camel or in the manual pages.

Here are some Perl operators and functions that care about context:

Table 5-4. Context-senstive functions

What? Scalar context List context
reverse() Reverses characters in a string Reverses the order of the elements in an array
each() Returns the next key in a hash Returns a two-element list consisting of the next key and value pair in a hash
gmtime() and localtime() Returns the time as a string in common format Returns a list of second, minute, hour, day, etc
keys() Returns the number of keys (and hence the number of elements) in a hash Returns a list of all the keys in a hash
readdir() Returns the next filename in a directory, or undef if there are no more Returns a list of all the filenames in a directory

There are many other cases where an operation varies depending on context. Take a look at the notes on context at the start of perldoc perlfunc to see the official guide to this: "anything you want, except consistency".

You can also use perldoc -f functionname to get the documentation for just a single function.