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