my $new_contents = my_test($old_content); sub my_test { my $long_content = $_[0]; # do some stuff here return $long_content; } #### $main_vars{content} = $old_content; my $new_contents = my_test(); $old_content = $main_vars{content}; sub my_test { # do some stuff here with $main_vars{content} }