Question about electronic density differences with perl script in dmol3

Hello, communitors

I tried to calculate electronic density differences with perl script in dmol3 (you can download it from community site)

I edited few lines and tried to calculate  electronic density differences however in 232 line it was error when i did debug.

the error message is following as Failed to export document to C:\\Users\\KANGSUNWOO\\Documents\\Materials Studio Projects\\New-Graphene with CdSe Calc Files\\~TASK_1708\\GwithCd3Se3.xsd.

- bad allocation in DMol3.Energy (function/property "Run") at -e line 232.

failure running DMol3 on GwithCd3Se3

the parts of perl script, which are related to error message are following as (the underline and bold type line is 232)

# This routine runs DMol3 on the input document and checks for errors.
# If "type" eq "energy" it does single-point energy
#           eq "optimize" it does optimization
# It it completes ok it returns 1
# If job fails then it prints a message and returns 0
    my (\\\$doc, \\\$type) = @_;
    my \\\$output;
    my \\\$RanOK = 0;
   
    # delete any existing field with the same name
    my \\\$fieldOld;
    eval {\\\$fieldOld = \\\$doc->UnitCell->Fields("\\\$fieldName");};
    if (\\\$@) {
      # Error accessing field, hence field does not exist
      #print "No field named \\\$fieldName from document ". \\\$doc->Name . "\\n";
    } else {
      # delete this field
      print "Deleting old field named \\\$fieldName from document ". \\\$doc->Name . "\\n";
      \\\$fieldOld->Delete;
    }
   
    print "Starting DMol3 job for " . \\\$doc->Name . "\\n";
   
    if (\\\$type eq "energy") {
    eval {\\\$output =  Modules->DMol3->Energy->Run(\\\$doc);};
    } else {
        print "Unkown type of calculation requested: \\\$type\\n";
        \\\$RanOK = 0;
        return \\\$RanOK;
    }
   
    if (\\\$@) {
# Some error occured
#print error message and move on to the next element
print "!!!!!!!!!!!!!!!!!!! ERROR !!!!!!!!!!!!!!!!\\n";
print \\\$@;
\\\$RanOK = 0;
    } else {
        # Calculation has completed successfully, carry on 
\\\$RanOK = 1;
print "Successful DMol3 completion for " . \\\$doc->Name . "\\n\\n";
    }
    return \\\$RanOK
}

if here is someone, who tried to this perl script calculations in dmol3, know this one

please give me detail information. (i really need detail explaination)

I also attached files of perl script