1

I have been trying to invoke a method of a python class from perl and is as below

parser.py

Class ABC(object):
  def __init__(self, input_file, output_file):
     ....

  def method1(self):
     ....

I want to Invoke this method abc from a perl script. The logic is

obj = ABC(input_file, output_file)
obj. method1()

Tried something like below in perl but in vain

use Inline Python => <<"END_OF_PYTHON_CODE";

from parser import ABC
END_OF_PYTHON_CODE

It throws error that ImportError: No module named parser

Can someone help me here?

2
  • 1
    You should probably go back and accept some answers to your previous questions Commented Dec 13, 2012 at 11:03
  • 1
    Done. Earlier I didn't know how to do that. Commented Dec 13, 2012 at 11:21

1 Answer 1

1

Checked within inline python ,they provides example code like this: does it work? Please check if parser.py is in your PYTHONPATH.

 use Inline Python;

   my $obj = new Myclass;

   __END__
   __Python__

   from mylibrary import myclass as Myclass
Sign up to request clarification or add additional context in comments.

3 Comments

That doen't seem to work and throws the error "Missing right curly or square bracket at abc.pm line 160, at end of line"
Count your curly brackets then. You're missing a closing bracket.
All the braces seem to be fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.