This function allows you to search arbitrarily large/complex data structures for particular elements. You can search hash keys, or hash/array values, for a number/string or regular expression. The datasearch function can return either the found hash keys, the found values (which could be data structures themselves) or the container of the key or value (which is always going to be a data structure)

By default, hash keys are searched, and the corresponding values are returned. To search hash or array values, specify SEARCH => 'values'. To search both values and keys, specify SEARCH => 'all'.

To find an exact match of a string, set FIND => 'string'. To use a regular expression use the qr operator: FIND => qr/^name.*/i FIND may also be a 2 element array, to search for a key-value pair.

You can also return the data structure containing the found key/value.

To do that, specify RETURN => 'container'. This will return the immediate container, either a hash or an array reference. You can also choose to get the closest hash container (even if the value was inside an array) by specifying RETURN => 'hashcontainer'.

Similarly, you can return the closest array container (even though the value found was a hash value or hash key) by specifying RETURN => 'arraycontainer'

Also, you can get an outer container by doing RETURN => 'container:xyz' in which case the container returned would be a structure pointed to by key xyz (if found to contain the search element somewhere inside it). Please see the examples at the end of this document.

ARGUMENTS The following arguments are accepted (case-insensitively). The only mandatory arguments are DATA and FIND.