## 37.4. Global Values in PL/Perl

You can use the global hash `%_SHARED` to store data between function calls. For example:

    CREATE OR REPLACE FUNCTION set_var(name text, val text) RETURNS text AS $$
        if ($_SHARED{$_[0]} = $_[1]) {
            return 'ok';
        } else {
            return "can't set shared variable $_[0] to $_[1]";
        }
    $$ LANGUAGE plperl;

    CREATE OR REPLACE FUNCTION get_var(name text) RETURNS text AS $$
        return $_SHARED{$_[0]};
    $$ LANGUAGE plperl;

    SELECT set_var('sample', 'Hello, PL/Perl!  How's tricks?');
    SELECT get_var('sample');