Re: Perl/sh/bash scripts and emacs



Marilyn Sander wrote:
>
> thank you very much for the trouble you have taken with your answer.
> I acknowlege that our script
> is not the same as the example in "Programming Perl". We really need
> to have the leading bash code there to choose what directory to execute
> Perl from. My question is still, is there a way to have that leading
> bash code and still have emacs see the file as a Perl script.
>
> I agree the documentation you've quoted does not say that it's
> possible. I just thought that the example in "Programming Perl"
> suggested there ought to be a way to do it. I've been guessing
> and trying different combinations, since there is no explicit
> rule or example. If I try
> #!/bin/bash -- # -*- perl -*- -x
>
> Perl gives the error message
> Can't emulate -x on #! line.
>
> The documentation you've quoted does not say explicitly that it's
> possible to construct this sort of script and have emacs recognize it.
> Perhaps it isn't. Do you know whether it is possible, and if so,
> how to do it?
>
> Please note, I am not an emacs user. The emacs user in question
> doesn't know how to do this, either.

I am not an emacs user either but I would assume from reading the docs that
you could do something like this:

#!/bin/bash

# shell code here

exec $perl -x $0 ${1+"$@"}

#! -*- perl -*- -w

# perl code here

__END__

something else here



John
--
use Perl;
program
fulfillment
.



Relevant Pages

  • Re: Perl/sh/bash scripts and emacs
    ... is not the same as the example in "Programming Perl". ... bash code and still have emacs see the file as a Perl script. ... I just thought that the example in "Programming Perl" ... I am not an emacs user. ...
    (perl.beginners)
  • 2005-10-23 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)
  • 2005-10-23 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)
  • 2005-10-23 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)
  • 2005-11-20 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)