Error in script

How to eliminate "requires explicit package" error from script? Any platform where we can learn script writing in material studio (any reference)?

#!perl

use strict;
use Getopt::Long;
use MaterialsScript qw(:all);

my \\\$repeatUnit = Documents->Import("structures://repeat-units/olefins/ethylene.msi");
my \\\$polymer = Tools->PolymerBuilder->Homopolymer->Build(\\\$doc, \\\$repeatUnit, 10);


output:

Global symbol "\\\$doc" requires explicit package name at -e line 8.
Execution of -e aborted due to compilation errors.


Answers 1
JW
JW 2021-05-23 Best Answer

Hi, 
This message is saying you have not declared what $doc is before using it in the Build. (Actually if you run the Check Syntax on the script it will suggest this is the problem). Add 

my $doc = Documents->New("polymer.xsd");

as a declaration to fix it.

There are two tutorials introducing scripting in the Help - That's as good a place to start as any. There are also lots of example scripts on this community that are worth looking through too.
best regards,.    

​​​​​​​James