#!perl use warnings; use strict; use Lexical::Persistence; # Create a new dynamic closure. my $dc = Lexical::Persistence->new(); # Prime a variable with a value. $dc->set_context( _ => { '$cat' => "persistent" } ); # Call a function within it. $dc->call(\&function); exit; sub function { # $cat is already initialized. print "persistent cat is '", my($cat), "'\n"; }