[comp.lang.perl] Starting a perl script

shawn@willow.MV.COM (Shawn M. Rogers) (03/21/91)

Hi,

I've got a pretty simple question that is driving me crazy...

I'm running SCO XENIX 2.3.2 and am using perl 3.44. My shell does not
use the "#!" that is used in many shell scripts at the beginning.

According to the nutshell handbook on perl, a way around this is
by replacing the "#!" line with the following:

eval '/usr/bin/perl -S $0 ${1+"$@"}'
	if 0;
[perl script here....]

This works to some degree... The perl script runs, but then when it
finishes executing, I get an error.  Here is an exaple:

*** SCRIPT ****
eval '/usr/bin/perl -S $0 ${1+"$@"}'
	if 0;
print "Howdy, world!\n";

*** OUTPUT ***
Howdy, world!
howdy: syntax error at line 4: `end of file' unexpected

Can anybody tell me why I'm getting this error when the script runs?
Is there a way around it?

Please email your response unless you think it would be of general
interest....and, thank you for your help in advance!


Shawn

-- 
Shawn M. Rogers                                         shawn@willow.MV.COM
176 East Street #205A    ..{decvax | harvard}!zinn!wgc386!slum!willow!shawn
Methuen, MA  01844                     ...uunet!samsung!wizvax!willow!shawn

merlyn@iwarp.intel.com (Randal L. Schwartz) (03/22/91)

In article <224@willow.MV.COM>, shawn@willow (Shawn M. Rogers) writes:
| According to the nutshell handbook on perl, a way around this is
| by replacing the "#!" line with the following:
| 
| eval '/usr/bin/perl -S $0 ${1+"$@"}'
| 	if 0;
| [perl script here....]

Missing an "exec" in there.  It's wrong on page 5, although it's correct
on page 216.  Try:

eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
	if 0;
[perl script here....]

The typo is already noted on the Perl 4.0 manpage.  (Read the *fine*
manpage. :-)

@a = (Just,another,Perl,"hacker,"); print "@a";
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/