#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @pkgs = qw( One Two ); foreach my $pkg ( @pkgs ) { # this is the part I can't figure out... Test::$pkg::hello($pkg); } package Test::One; sub hello{ my $var = shift; print "Hello: $var\n"; } 1; package Test::Two; sub hello{ my $var = shift; print "Hello: $var\n"; } 1;