PHP Manual

PEAR Manual

Smarty Manual

PostgreSQL

MySQL Manual

Perl Manual

-- perl 5.8.8 documentation --
reverse
  • reverse list

    in list context, returns a list value consisting of the elements of list in the opposite order. in scalar context, concatenates the elements of list and returns a string value with all characters in the opposite order.

        print reverse <>;		# line tac, last line first
        undef $/;			# for efficiency of <>     print scalar reverse <>;	# character tac, last line tsrif

    used without arguments in scalar context, reverse() reverses $_ .

    this operator is also handy for inverting a hash, although there are some caveats. if a value is duplicated in the original hash, only one of those can be represented as a key in the inverted hash. also, this has to unwind one hash and build a whole new one, which may take some time on a large hash, such as from a dbm file.

        %by_name = reverse %by_address;	# invert the hash