#!/usr/bin/perl use strict; # Use good practices use warnings; my %globals = (barbaz => "something here"); foo("bar", "baz"); sub foo { my $name = join('', @_); # Build varname print $globals{$name}, "\n"; # use it at will.... }