my %hash; my $blah = function(\%hash); warn Dumper \%hash; # prints a bunch of values #### sub function { my ($hash) = @_; tie %$hash, 'Apache::Session::File', undef, { Directory => $r->dir_config('blah'), LockDirectory => $r->dir_config('blah'), }; $hash->{auth}->{user} = "jacques" } #### sub function { my ($hash) = @_; $hash = MyModule::tie_session(); $hash->{auth}->{user} = "jacques"; } #### Package MyModule; use Apache::Session::File; sub tie_session { my $hash = {}; eval { tie %$hash, 'Apache::Session::File',undef, {Directory => $r->dir_config('Blah'), LockDirectory => $r->dir_config('Blah'), }; }; return $@ if ($@); return $hash; } 1;