# Example of using variable names for variables, # that I find useful. #------------- # user defined code # ------------ my $some_var_list = var_from_env_var("list"); my $some_var_source = var_from_env_var("source"); my $some_var_other = var_from_env_var("other"); print "list=> $some_var_list\n". "source=>$some_var_source\n". "other=> $some_var_other\n"; # ------------ # my module # ------------ sub var_from_env_var { # could use this, or some other complex method # of determining the default value. my $list_def = $ENV{"LIST_VAR"} || $ENV{"LIST_VAR_DEPRECIATED"} || "other_list"; my $source_def = $ENV{"SOURCE_VAR"} || $ENV{"SECONDARY_SOURCE"} || "other_source"; # is there another way to use a variable to point # to a variable other than eval? my $input = shift; my $result = eval "\$$input"."_def"; return $result if (defined ($result)); return $input; }