is it possible, to use, or otherwise import and access the class in a .pm file by a suggested name (this would be after compilation)...

here's the lowdown, I've been working on a project for a while now, it is an XML processor. One of the parts of a process may involve reading a process definition file, these files rarely change. The time to parse out that type of file is only neccessary while the file is in a development stage; that is, once the process instructions are decided, the same file could be represented as a series of instructions in Perl.

So, I've made those files optionally compilable, (I should note, this project is online, so I compile the files online aswell). Compilation involves reading an XML nodetree and turning it into a series of statements to build a Perl object structure.. And that object can then be "imported" into another XML file, in place of a statement to parse and process the original process instruction XML file.

Anyway, all is good, except for one thing, I can't seem to get a "use" block to work in an eval statement when I'm testing this online. On my PC, that seems to work fine.... o_O.

Is there any other way to do this, without importing all of the files in my "compiled objects" folder everytime I run a process (all processes go through the same controller)... If you can interpret what I'm doing at the moment, you'll find it amusing:

sub do_housekeeping{
	my(@files) = glob("$quasi_path"."qsi_*.pm");
	open my($out),"> ".$quasi_path."Compiled.pm" or return($!);
	print $out '#!/usr/bin/perl';
	print $out "\n";
	print $out 'package Fuse::Handlers::Quasi::Compiled;';
	print $out "\n";
	for(my($i) = 0; $i <= $#files;$i++){
		if($files[$i] =~ m|([\w\d]*)\.pm|){
			print $out 'use Fuse::Handlers::Quasi::'.$1.';';
			print $out "\n";
		}
	}
	print $out "1;";
}

The only problem with that is; if I "use" everything in every process, I'm gonna lose that slice of time I gained by compiling files in the first place -_-

Ahh... solved it... Seems on my server I have to put everything in the eval block, pull the resultant object out of the eval block, AND explicitly define just where the eval is...

Something like this:

sub loadup{
	my($fuser,$objectname) = @_;
	my($fullname) = "qsi_$objectname";

	my($lib) = "use lib '/home/fusion/public_html/fuse-cgi/';";
	my($get) = "use Fuse::Handlers::Quasi::$fullname;";
	my($ret) = "return (Fuse::Handlers::Quasi::$fullname->new())";

	my($local_object) = eval($lib.$get.$ret);

	$local_object->{my_owner} = $fuser;
	die($@) if $@;
	$local_object->unpack();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.