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

Hi

is there a recommended way to mix Perl and eLisp code in one file without caring about escaping, such that it can be executed in both ways?

Something like

my $perl; #code ... __DATA__ (ELisp...)

Just that emacs ignores the Perl part when executing the file?

There are similar examples with bash and bat...

update

Just realising that ; is a comment symbol in lisp and a no op in Perl, this might be simplistic way to do it. ..

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

Replies are listed 'Best First'.
Re: [emacs] dual files mangling Perl and Lisp code?
by choroba (Cardinal) on Sep 19, 2017 at 08:53 UTC
    Yes, and __DATA__ (or __END__) doesn't need a line for itself as I believed:
    ; print "Hello world!\n"; ;__DATA__ (message "Hello world!")

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      > doesn't need a line for itself as I believed:

      ; print "hello " ; print "choroba" __DATA__ # unbelievable BEGIN { die "broken" }

      indeed unbelievable ... :)

      Need to test on linux if the shebang is still accepted.

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

Re: [emacs] dual files mangling Perl and Lisp code?
by ikegami (Patriarch) on Sep 19, 2017 at 18:21 UTC

    You might find perl -x useful.

      Thanks I already forgot that -x option again.

      But this implies I can find something similar to __END__ in eLisp.

      I seem to remember that I can manipulate the "cursor" during code interpretation, probably a way to go.

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

Re: [emacs] dual files mangling Perl and Lisp code?
by thanos1983 (Parson) on Sep 19, 2017 at 09:22 UTC

    Hello LanX,

    I found this module Emacs::Lisp is this something that you could apply?

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
      > something that you could apply?

      Not for this problem, but hopefully for something else ...

      Thanks! :)

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

Re: [emacs] dual files mangling Perl and Lisp code?
by karlgoethebier (Abbot) on Sep 19, 2017 at 16:20 UTC

    He! How cool is that?

    May i ask for what esoteric issue you need it?

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

        Thanks LanX. And especially for the link. Regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

        perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Re: [emacs] dual files mangling Perl and Lisp code?
by hotchiwawa (Scribe) on Sep 22, 2017 at 11:47 UTC
    Hi Lanx, The goal was to create an Emacs script in lisp/perl ?