#!/usr/bin/perl use strict; use warnings; use Devel::Symdump; $| = 1; my $code; my $program=shift @ARGV; die ("usage: $0 [...]\n") unless ($program); open (PRG, $program) or die "cant open '$program'\n"; my $symdumpcode = " \$main::obj=Devel::Symdump->rnew('ThisIsAnotherPackageAndMostLikelyWillNeverCollideWithAnyOtherNamespace'); print \$main::obj->as_string(); "; my $idx=0; foreach my $arg (sort {$a <=> $b} @ARGV) { while () { $idx++; $code .= $_; last if ($arg == $idx and $code .= $symdumpcode); } } close PRG; eval "package ThisIsAnotherPackageAndMostLikelyWillNeverCollideWithAnyOtherNamespace; $code"; print $@ if ($@);