use Path::Tiny; use Time::Piece; use Util::H2O; my $ref_var = h2o { abs => path(__FILE__)->absolute, cwd => Path::Tiny->cwd, }, qw/ save_file ... /; init_vars($ref_var); print $ref_var->save_file, "\n"; sub init_vars { my $rvars = shift; # ... $rvars->save_file( path( $rvars->cwd, "games", localtime->strftime("%d-%m-%Y-%H-%M-%S.txt") )->touchpath ); # ... }