[comp.lang.perl] Strange behavior with require

victor@arnor.uucp (02/12/91)

Last week I built perl 3 patch level 44 for the two sets of
workstations that we have here: Sun 4's and IBM RT/PC's running bsd
4.3.  Both built just fine, and passed all tests.  Just today I
decided to try the Date subroutines and calculator.  On the Sun's it
worked just fine (we have shared file systems under NFS).  But on the
RT's I get the following output when I run dtc:

dtc[3]: require:  not found
dtc[5]: =:  not found
        Date Calculator version 1.0

dtc[7]: h for help)\n":  not found
           (type
>
dtc[8]: syntax error at line 10 : `)' unexpected


Strangely enough, I can successfully run other scripts having require.
In fact if I change the require to include, the same behavior ensues.
If I comment it out, things start running ok, but, of course, the
subroutines in the require'd file aren't found.  For sake of
reference, the beginning of dtc is:

#!/usr/local/bin/perl -I/homes/irt/victor/perl

require 'date.pl';

$command = '';
print "	Date Calculator version 1.0\n";
print "	   (type `h' for help)\n";
print "> ";


Does anybody have a clue as to what could be wrong?
--
			Victor S. Miller
			Vnet and Bitnet:  VICTOR at WATSON
			Internet: victor@ibm.com
			IBM, TJ Watson Research Center

victor@arnor.uucp (02/12/91)

I tracked down the source of the strange behavior:  It was the -I on
the #! line.  It seems that on the rt/pc bsd systems (and on AIX 3 on
rs/6000's) that any argument on the #! line is truncated to 8
characters.  But that's not all: if the argument is indeed truncated
some other horrible junk is passed to perl which causes it to become
extremeley confused.  I've decided to include the line below in all my
perl scripts:

@INC = split(/:/,$ENV{'PERLINCLUDE'}) if defined $ENV{'PERLINCLUDE'};

and then set the environment variable PERLINCLUDE to be a path list
for my include files.  Does anyone have any other suggestions?
--
			Victor S. Miller
			Vnet and Bitnet:  VICTOR at WATSON
			Internet: victor@ibm.com
			IBM, TJ Watson Research Center

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/12/91)

In article <VICTOR.91Feb11144812@irt.watson.ibm.com> victor@ibm.com writes:
: Last week I built perl 3 patch level 44 for the two sets of
: workstations that we have here: Sun 4's and IBM RT/PC's running bsd
: 4.3.  Both built just fine, and passed all tests.  Just today I
: decided to try the Date subroutines and calculator.  On the Sun's it
: worked just fine (we have shared file systems under NFS).  But on the
: RT's I get the following output when I run dtc:
: 
: dtc[3]: require:  not found
: dtc[5]: =:  not found
:         Date Calculator version 1.0
: 
: dtc[7]: h for help)\n":  not found
:            (type
: >
: dtc[8]: syntax error at line 10 : `)' unexpected

Note that these are *shell* error messages, not Perl messages.  That's
your clue.

: Strangely enough, I can successfully run other scripts having require.
: In fact if I change the require to include, the same behavior ensues.
: If I comment it out, things start running ok, but, of course, the
: subroutines in the require'd file aren't found.  For sake of
: reference, the beginning of dtc is:
: 
: #!/usr/local/bin/perl -I/homes/irt/victor/perl
: 
: require 'date.pl';
: 
: $command = '';
: print "	Date Calculator version 1.0\n";
: print "	   (type `h' for help)\n";
: print "> ";
: 
: 
: Does anybody have a clue as to what could be wrong?

Your #! line is obviously not working right, probably because it's too
long.  First, make sure perl really is in /usr/local/bin.  Then change
the front of the script to this:

#!/usr/local/bin/perl

unshift(@INC, "/homes/irt/victor/perl");
require 'date.pl';

Larry

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (02/16/91)

As quoted from <VICTOR.91Feb11164756@irt.watson.ibm.com> by victor@arnor.uucp:
+---------------
| I tracked down the source of the strange behavior:  It was the -I on
| the #! line.  It seems that on the rt/pc bsd systems (and on AIX 3 on
| rs/6000's) that any argument on the #! line is truncated to 8
| characters.  But that's not all: if the argument is indeed truncated
| some other horrible junk is passed to perl which causes it to become
| extremeley confused.  I've decided to include the line below in all my
| perl scripts:
+---------------

Actually, those weren't Perl error messages; they were ksh error messages.
Does AIX understand #!?  Or did it punt to the shell when it saw a #! line
that it couldn't digest?

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY