#-------------------- # Option #1: use strict; my %lists = ( 'test1' => sub { print "New message for test1\n"; }, 'test2' => sub { print "New message for test2\n"; } ); for my $i ( keys %lists ) { $lists{$i}->(); } # ------------------- # Option #2: use strict; sub test1 { print "New message for test1\n"; } sub test2 { print "New message for test2\n"; } my %lists = ( 'test1' => \&test1, 'test2' => \&test2 ); foreach my $i ( keys %lists ) { $lists{$i}->(); }