Not sure how much of a beginner question this is. I've been searching mail archives and can't find anything about it. I've embarrassed myself by giving advice based on my reading of the Camel book, but the advice doesn't work.
In the "Camel" book "Programming Perl", Chapter 19 is a chapter on using the Perl command line. One example there is to use #!/bin/sh -- # -*- perl -*- eval 'exec perl -S $0 ${1+"$@"}' if 0; The explanation says that the presence of -*- perl -*- on the shebang line causes perl not to pay attention to that line, but does cause emacs to treat the script as a perl file. But we'd like to be able to use sh or bash to locate one of several okay versions of Perl. The path to Perl differs depending on what installation it is run in. We cannot just use the user's path or environment, because these scripts are used in strictly-managed configuration management/QA/build/release processes. Each one has to use a particular version and installation of Perl and no other. We have got something that works quite well, except that an emacs user complains that emac doesn't recognize the script header as Perl, and instead provides shell highlighting instead of Perl highlighting. Hence my question is, how do we accommodate the emacs user? The following code works well (pathname specifics changed for confidentiality): #!/bin/bash -- # perl1="/path1/perl" perl2="/path2/perl" if [ -x $perl1 ] then perl=$perl1 elif [ -x $perl2 ] then perl=$perl2 else echo Unable to find perl, contact local suport person exit 2 fi exec $perl -x $0 "$@" #!/dummydir/perl -w $myname=`basename $0` ; chomp $myname; $mydir=`dirname $0` ; chomp $mydir; $mydir=`(cd $mydir; pwd)`; chomp $mydir; print "I am $myname in directory $mydir\n"; print "My options are:\n"; for $a ( @ARGV ) { print "$a "; } $onlyonce=1; print "\n"; exit 0; --------------------------------------- Perl gets control, skips the bash code, finds the second shebang line, honors the -w flag, and runs the script. But if we change the initial shebang line to #!/bin/bash -- # -*- perl -*- then Perl does not skip the bash code, and gives lots of error messages. So it looks like the advice in the Camel book is no good. Either that or I've forgotten how to read a technical manual. Can someone help? thanks, --Marilyn Sander -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>