#!/usr/bin/perl use strict; use warnings; my %test; %test = ( foo => { foo => 'bar', code => sub { my ($ref) = @_; 'ja' if $ref eq $test{foo}{foo}; } } ); print &{$test{foo}{code}}('bar'),"\n";