in reply to Dynamically create Packages

You may be able to get what you want by messing with %INC:

my $path = $package; $path =~ s{::}{/}g; $path .= '.pm'; $INC{$path} = '(eval)';

There may be something better to use than '(eval)'. It's just the first thing I thought of. When you then use the package again, it sees the entry in %INC and thinks it's already been loaded.

Replies are listed 'Best First'.
Re^2: Dynamically creat Packages
by Herkum (Parson) on Nov 04, 2008 at 17:55 UTC

    I understand the first part, but I don't get what the '(eval)' is supposed to be.

      It's just a true value. For other packages, %INC contains the full path to the file that provided it. Since it's not coming out of a file here, I just put '(eval)' like what caller says when it also would otherwise name something specific.