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

I'm using cperl-mode in emacs for experimenting with perl6.

I don't care much about highlighting at the moment, but does anyone have an idea how to set up M-x mode-compile to decide by the shebang when to run P5 or P6 ?

These are the default settings M-x customize-group RET compile-perl :

Compile Perl group: Perl compilation options State : visible group members are all at standard values. Perl Command: perl State : STANDARD. Command to run perl. Perl Dbg Flags: -w State : STANDARD. Flags to give to perl for debugging a Perl script.

I tried to replace perl with bash , but that doesn't seem to be the way to respect the shebang (any shell command to do so?)

I could - as a workaround - define a "file-local variable"

#-*- perl-command: perl6 -*-

But I'd prefer a way to evaluate the she-bang, in order to be editor agnostic.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re: [emacs] [perl6] how to set mode-compile to respect the shebang
by duelafn (Parson) on Feb 19, 2016 at 02:15 UTC

    I don't know any "proper" ways of doing it, but defining an execbang script isn't too hard. This should work if you set it to your Perl Command:

    #!/usr/bin/perl use strict; use warnings; # use #! from first argument which is a file: my ($file) = grep -f $_, @ARGV; # alternative: use #! from last argument: # my $file = $ARGV[-1]; open my $F, "<", $file or die "Error reading $file: $!"; exec $1, @ARGV if <$F> =~ /^#!(\S+)/; exit 1;

    Good Day,
        Dean