Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've got a program written which runs fine on perl 5.8.0, but due to things beyond my control it needs to work with perl 5.005. Currently it does not. I get the following error on the line use custom_package;
BEGIN failed--compilation aborted at file.pl line 4 followed by  Premature end of script headers: file.pl (yes this is from an apache log)
those are all the errors I get so I'm not really sure where to start

about all I can think of that might be causing this error (I began coding in perl after 5.8.0 was released and cannot find any information on this older version of perl) is that line 3 is use lib '/home/cgi/programs/libraries'; which has custom_package.pm inside of it.
But I don't really know..... if that is the case is there a solution that will work for both this older version of perl and 5.8.
I am aware of the existance of require, but it is my understanding that you cannot do things like custom_package::function(argument); with require which would make life a bit more frustrating as I would have to recode a lot in order to accomodate that.

Replies are listed 'Best First'.
Re: Compatiblity with older perls
by bart (Canon) on Apr 06, 2004 at 19:28 UTC
    You're overreacting. Perl 5.005 wasn't that primitive compared to 5.8.x. The major differences of 5.005 towards 5.8.x in my mind (I could be overlooking some) are:
    • No support for Unicode/UTF-8 whatsoever
    • No our — use use vars instead.
    I was thinking of the 4th argument to substr too, but apparentlythat was already part of 5.005.

    If I were you, I'd focus on these two, first. I can't say I've ever used one of the other newer features.

      Yeah... more than anything, I'd say that our ( $var1, @var2, %var3 ); versus use vars qw( $var1 @var2 %var3 ); is the biggest issue in code compatibility back to 5.005. Always a good place to start looking.
      ------------ :Wq Not an editor command: Wq
      Also, "use warnings" is very popular in newer modules, but not available for perl 5.005.
Re: Compatiblity with older perls
by simonm (Vicar) on Apr 06, 2004 at 19:07 UTC

    The "use lib" line is probably not the problem.

    Take a look at custom_package.pm and make sure it doesn't have a line like "require 5.006" or "use 5.8" somewhere near the beginning.

    You might try running it from a command line to see if you pick up any warnings or other information that's not showing up in the log.

      hmmmm.... I looked in custom_package.pm and it doesn't have a require 5.006 or use 5.8 (or any of the possible varients within it) the closest I've got is require 5.000, which is just fine
      I would run it off of the command line, except that I don't have a shell account on that server - just ftp (insecure as it is...)

      really good idea, but sadly that was not the problem. Any other thoughts?

Re: Compatiblity with older perls
by fglock (Vicar) on Apr 06, 2004 at 21:20 UTC
Re: Compatiblity with older perls
by suaveant (Parson) on Apr 06, 2004 at 19:08 UTC
    the old way is
    push @INC, '/home/cgi/programs/libraries';
    possibly in a BEGIN block...

                    - Ant
                    - Some of my best work - (1 2 3)

      I put the push statement in and commented out the use lib one, sadly I still get the exact same error.......
        it says it is failing compilation on line 4... what is one line 4? Can you show us at least part of the code. A useful thing for CGI is
        use CGI::Carp qw(fatalsToBrowser);
        reports fatal errors in html... handy for devel work.

                        - Ant
                        - Some of my best work - (1 2 3)