#!/usr/bin/perl $barbaz = "something here"; foo("bar", "baz"); sub foo { $name = join('', @_); # Build varname print $main::{$name}, "\n"; }