Using modules with polymake

Questions and problems about using polymake go here.

Moderator: Moderators

mjs
Posts: 7
Joined: 15 Mar 2019, 04:15

Using modules with polymake

Postby mjs » 15 Mar 2019, 04:25

I have what I suspect is a newbie question regarding writing perl modules for use in the polymake shell. Here is a minimal broken example that demonstrates my problem. I save the following in a file "example.pm" in my working directory:

Code: Select all

package example; use strict; use warnings; use application "polytope"; sub my_test_routine { my $v = new Vector([1,0,0]); return $v; } 1;
In the polymake shell, I do the following:

Code: Select all

polytope > use example; polytope > $v = example::my_test_routine();
And then I get the error

polymake: ERROR: Can't locate object method "new" via package "Vector" at example.pm line 7.

Is there an easy fix for this?

User avatar
gawrilow
Main Author
Posts: 340
Joined: 25 Dec 2010, 17:40

Re: Using modules with polymake

Postby gawrilow » 16 Mar 2019, 16:25

Either load your code with "script" instead of "use", or put the line "package example" after "use application". This restriction is unfortunate but currently unavoidable.

BTW "use warnings" and "use strict" are redundant, all scripts in polymake are always interpreted this way.

mjs
Posts: 7
Joined: 15 Mar 2019, 04:15

Re: Using modules with polymake

Postby mjs » 26 Mar 2019, 10:23

This worked. Thank you for your help!


Return to “Helpdesk”