使用“严格限制”时不允许使用关键字

时间:2018-08-10 04:11:32

标签: perl material-design

我是高阻隔橡胶材料的研究人员。通过使用Materials Studo软件,我遇到了Perl的一些问题。我不明白Perl错误的含义。

这是Perl脚本及其错误

#!perl

use strict;

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

for ( my $RxnRadius = my $MinRxnRadius; $RxnRadius <= my $MaxRxnRadius; $RxnRadius += 0.5 ) {

    my $xsdNameDist = sprintf( "%s_R%.2f", my $rootName, $RxnRadius );    #rename the new structure;

    if ( $RxnRadius > $MinRxnRadius ) {

        my $doc->Name = $xsdNameDist . "_init";
        ForciteGeomOpt( $doc, 20000 );                                    # run 20000 steps of Geometry Optimization

        my $results = ForciteDynamics( $doc, my $steps, "NPT" );
        $results->Trajectory->Delete;
    }

    for ( my $iteration = 1; $iteration <= my $IterationsPerRadius; $iteration++ ) {

        my $doc->Name = $xsdNameDist . "_" . $iteration;
        my $numBonds = createNewXlinks( $doc, $RxnRadius );
        my $reactedOligomerAtoms = 0;

        foreach my $atom ( @{ $doc->UnitCell->Atoms } ) {
            my $oligomerReactiveAtom;
            $reactedOligomerAtoms++ if ( $atom->Name =~ /^$oligomerReactiveAtom-\d/ );
        }

        my $conversion = 100 * my $totalOligomerAtoms;

        ( $reactedOligomerAtoms / $totalOligomerAtoms );

        if ( $numBonds == 0 ) {
            last;
        }

        optimizeAndPerturb( $doc );

        my $rowCounter;
        xlinkStatistics( $doc, $RxnRadius, $rowCounter );
        maxBondEnergy( $doc, $RxnRadius, $rowCounter ) if ( my $UseMaxBondEnergy );

        my $analysis_doc = Documents->New( "analyze.xsd" );
        $analysis_doc->CopyFrom( $doc );

        my $analyzeDuration;
        my $timeStep;

        my $steps   = ( $analyzeDuration * PICO_TO_FEMTO / $timeStep );
        my $freq    = int( $steps / 20 ); ### line 56
        my $results = Forcite Dynamics(
            $analysis_doc, $steps,
            "NPT",
            ( TrajectoryFrequency => $freq )
        );

        getTrajTempAndPressure( $results, $rowCounter, $RxnRadius );
        getEnergies( $results, $rowCounter );
        $analysis_doc->Delete;
        $results->Trajectory->Delete;

        if ( $conversion >= my $conversionTarget ) {

            my $numbondsDelete = my $xlinkCounter - $reactedOligomerAtoms - my $targetOligomerAtoms;

            if ( my $deleteExcessXlinks and $numbondsDelete > 0 ) {
                deleteExcessBonds( $doc, $numbondsDelete );
                xlink Statistics( $doc, "Final", $rowCounter );
            }
            else {
                my $textDoc->Append(
                    sprintf "There  are no excess bonds to delete\n "
                );
            }

            my $textDoc->Save;

            last;
        }

        Documents->SaveAll;
    }

    last if ( my $conversion >= my $conversionTarget );
}

my $doc->Name = my $rootName . "_final";
analyzeBonds( $doc );
XlinkSet( $doc );
Glasstransitiontemperature( $doc );
Documents->SaveAll;

给予

  

在-e第56行使用“ strict subs”时,不允许使用关键字“ PICO_TO_FEMTO”。       -e出现编译错误。

我不了解通知或解决问题。

1 个答案:

答案 0 :(得分:2)

可能某种形式的PICO_TO_FEMTO是从您MaterialsScript开始的use库中导入的,因为它没有在脚本中定义。

看看lib。我的假设是,它的名称实际上是$PICO_TO_FEMTO,它是带有$符号的简单标量变量。

Perl中的裸词是没有标记的标识符。如果是函数,就可以了。但这可能是一个变量。

如果要定义裸字变量,请按以下步骤进行操作:

use constant PICO_TO_FEMTO => 1000;

这将创建一个名为PICO_TO_FEMTO的函数,该函数始终在后台返回1000。