I want to build a bunch of Perl subrotines that all have the same template `if elsif elsif else` that takes a decision based on a factor variable. Here's an example of subroutine template:

```
sub get_age{

  my $factor=shift;

  if    ($factor == 1 ){ print "do something" }
  elsif ($factor == 2 ){ print "do somthing2" }
  elsif ($factor == 3 ){ print "do somthing3" }
  elsif ($factor == 4 ){ print "do somthing4" }
  else                 { print "error"        }
  }

```

I am wondering if there some design pattern on Perl to replace the `if else` condition with more elegant solution which easy to maintain in the future specifically if I need to change some of the conditions or delete some of it?