Perl does different things on two different platforms

On Mac OSX, this works fine with perl

perl -v This is perl, v5.8.9 built for darwin-2level perl -e 'sub test {}' 

But on Solaris

 perl -v This is perl, v5.8.8 built for i86pc-solaris-thread-multi perl -e 'sub test {}' Illegal declaration of anonymous subroutine at -e line 1. 

Any ideas?

Thanks Kelly

+4
source share
2 answers

Most likely, this is the difference in behavior between the two versions of Perl. It is also probably just a bug in the CLI evaluation mode in 5.8.8

Try this test to see if it is just a CLI or Perl evaluation:

 use strict; sub test {} 

If it goes through strict mode in a file, it is probably as good as it is.

+3
source

perldoc perldiag says:

  • Invalid Anonymous Subroutine Declaration
    (F) When using the sub keyword to create an anonymous subroutine, you should always specify a code block. See perlsub

It may be located in the sitecustomize.pl file. He does not see the "test". He reads it as a 'sub' . Try typing perl -e 'test {}' at the command line.

Also, to extract the configuration file, you can add the -f switch to the command line. `perl -fe 'sub test {}'

perldoc perlrun for more information.

+1
source

All Articles