CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Create a dynamic Object

 



annabel
New User

May 17, 2010, 10:23 PM

Post #1 of 5 (1857 views)
Create a dynamic Object Can't Post

I'm trying to create an object dynamically using a string as the object type. It works for me with a simple example:

my $string = "Employee";

my $objct = new {$string}("First", "Last", 12345);

Employee is a derived class of a Person class. However, with my real code I get an error: Compilation failed in require at studyMngr.pm line 7. The line triggering it is:

my $nextStepbjct = new {$nextProcessStep}("name");

What's the difference between the two ways of using a dynamic object is beyond me.
I'm on a deadline with this. Help....


rovf
Veteran

May 18, 2010, 2:07 AM

Post #2 of 5 (1847 views)
Re: [annabel] Create a dynamic Object [In reply to] Can't Post

Probably different strictness?

I bet you don't get only "Compilation failed", but also a more meaningful error message - do you?

Also, please post a minimal version of the program which still shows the error.

Ronald


annabel
New User

May 18, 2010, 12:37 PM

Post #3 of 5 (1836 views)
Re: [rovf] Create a dynamic Object [In reply to] Can't Post

The full error message is given below.

The code is attached as a tar file. If you run:

perl ChIPSeqPipeline_main.pl it should generate the following error message:

Uncaught exception from user code:
Uncaught exception from user code:
Uncaught exception from user code:
Uncaught exception from user code:
syntax error at ChIPSeqPipeline_processStepMngr.pm line 134, near "}("
Compilation failed in require at ChIPSeqPipeline_studyMngr.pm line 7.
StudyMngr::BEGIN() called at ChIPSeqPipeline_processStepMngr.pm line 7
eval {...} called at ChIPSeqPipeline_processStepMngr.pm line 7
require ChIPSeqPipeline_studyMngr.pm called at ChIPSeqPipeline_main.pl l
ine 7
main::BEGIN() called at ChIPSeqPipeline_processStepMngr.pm line 7
eval {...} called at ChIPSeqPipeline_processStepMngr.pm line 7
BEGIN failed--compilation aborted at ChIPSeqPipeline_studyMngr.pm line 7.
require ChIPSeqPipeline_studyMngr.pm called at ChIPSeqPipeline_main.pl l
ine 7
main::BEGIN() called at ChIPSeqPipeline_studyMngr.pm line 7
eval {...} called at ChIPSeqPipeline_studyMngr.pm line 7
Compilation failed in require at ChIPSeqPipeline_main.pl line 7.
main::BEGIN() called at ChIPSeqPipeline_studyMngr.pm line 7
eval {...} called at ChIPSeqPipeline_studyMngr.pm line 7
BEGIN failed--compilation aborted at ChIPSeqPipeline_main.pl line 7.
Attachments: pipeline.tar (60.0 KB)


rovf
Veteran

May 19, 2010, 3:33 AM

Post #4 of 5 (1806 views)
Re: [annabel] Create a dynamic Object [In reply to] Can't Post

Sorry if we have a misunderstanding here, but when I wrote in my last response


Quote
please post a minimal version of the program


I did not mean a 60KB tar file. Is it really true that you can't reduce your program further to exhibit this error?

Ronald


FishMonger
Veteran / Moderator

May 19, 2010, 4:56 AM

Post #5 of 5 (1804 views)
Re: [rovf] Create a dynamic Object [In reply to] Can't Post

rovf,

FYI, this is a cross posted question.

http://bytes.com/topic/perl/answers/888357-create-dynamic-object

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives