Hello all!

I am new to Perl and have a question. I have to see about converting my
Python code to Perl for the project I am working on and I need to know how
to go about doing a very specific part of my code.

The flow of the code is as follows:

Using an hash (perl term, dict in Python terms), select a string from the
hash to get the name of a module to load dynamically.
Load the module into the interpreter dynamically
Using another string in the same hash, execute a function in the dynamically
loaded interpreter using the value in the string as the name of the
function, passing in a set of arguments.

The python code is basicly as follows:
'entry' is the hash (dict) that contains the module and function names.

                try:
                    mod = __import__(entry['module'])
                except ImportError, msg:
                    log('Failed to load module %s: %s' %
(entry['module'],msg))
                    sys.exit(0)
                if entry['test'] not in mod.__dict__:
                    log('Failed to run test %s in module %s: Does not exist'
% (entry['test'],entry['module']))
                    sys.exit(0)
                while 1:
                    try:
                        rtn = mod.__dict__[entry['test']](entry)
                    except:
                        import traceback, StringIO
                        r = StringIO.StringIO()
                        r.write('<HR>There was a software failure in
"%s.%s".</HR>' % (entry['module'],entry['test']))
                        r.write('Please report this entire message to
XXXXX<BR>')
                        r.write('<PRE>')
                        traceback.print_exc(file=r)
                        r.write('</PRE>\n')
                       
Thank you very much for any help you can provide!!
                                
Lance Ellinghaus
TWAI Operations Integration/Special Projects
Work Phone: 214-922-6458
Work Cell: 972-877-0409
Nextel: 142*52*5511
Home Phone: 940-271-1274
Email: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to