#!/usr/bin/perl -w use strict; my $pkgname = "Foobar"; eval qq{ package $pkgname; print "lots of stuff.\n"; }; package main; print "more stuff.\n";