#!/usr/bin/perl use v5.10; use strict; use warnings; sub example_sub { my $cfg = cfg_cache(); say $cfg->{x}; } sub cfg_cache { state $cfg = shift; return $cfg; } my $cfg = { x => "cat"}; cfg_cache($cfg); ## "cat" gets printed example_sub(); ## "mouse" gets printed. $cfg->{x} = "mouse"; example_sub(); ## but if I reset $cfg "mouse" still gets printed $cfg = { x => "rat"}; example_sub();