use strict; use constant ERR => 'Some error happened.'; use constant OK => 'All is fine.'; my %messages = ( 'ERR' => ERR(), 'OK' => OK(), ); my $res = some_func(); print $messages{ $res }, "\n"; #### use strict; use constant ERR => 'Some error happened.'; use constant OK => 'All is fine.'; my $res = some_func(); { no strict 'refs'; print &$res(), "\n"; };