Personal tools
You are here: Home / cmgui / Wiki / CMISS Perl Interpreter Quirks
Log in

Forgot your password?

CMISS Perl Interpreter Quirks

Don't be fooled into thinking that you can program ordinary Perl in comfiles. There are several important differences arising because of the necessity to allow interactive input.

Add any quirks you notice here.

  • Due to backwards compatibility with old CMISS commands the Perl Interpreter does not have a line delimiter character, semicolons are not required on the end of lines. Instead you cannot continue any command from one line to the next which is a real pain when initialising hashes. The following does not work even though it is legitimate perl:

      my %fred = {bob => 'happy',
                  rachel => 'excited',
                  fred => 'sad'};

Instead you have to write it all on one line:

  my %fred = {bob => 'happy', rachel => 'excited', fred => 'sad'};
  • Variables declared with 'my' only apply within the current scope. When you type code interactively then each line exists as a single entity (and therefore any 'my' variables will not exist as soon as that line returns). Therefore when you are working interactively do not use 'my'. However in your comfiles the best way to make things work properly is to use braces to correctly define the scope you want. This has the added advantage of having the whole file compile in a single call to perl and is therefore faster:

      use strict;
      my $bob;
      my @fred = ("fred1", "fred2", "fred3");
      $bob = $fred[1];
      print "$bob $fred[2]\n";
  • Post declared if ie '$x=1 if defined $foo;' doesn't work. Use 'if(defined $foo){$x=1}' instead.