Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Emacs: Submit a Perl Script

by mpettis (Beadle)
on Dec 17, 2007 at 22:01 UTC ( #657525=perlquestion: print w/replies, xml ) Need Help??
mpettis has asked for the wisdom of the Perl Monks concerning the following question:

Hi, This is more an Emacs question than Perl, but I haven't found much in the way of Emacs help... I am trying to transfer from UltraEdit to Emacs because I've heard such great things about it... I mostly develop Perl scripts, and one invaluable feature in UltraEdit is a Ctrl-Shift-0 tool I set up to submit the full name of the file of my active tab to Perl, and capture the output in the output box. Can someone point me to where there is similar functionality in Emacs? It seems like something basic that should have been baked in long ago, but I just can't seem to find it. Any help is appreciated, thanks, matt

Replies are listed 'Best First'.
Re: Emacs: Submit a Perl Script
by Joost (Canon) on Dec 17, 2007 at 22:16 UTC
Re: Emacs: Submit a Perl Script
by educated_foo (Vicar) on Dec 17, 2007 at 23:26 UTC
    M-x compile will give you almost what you want -- type in the command-line the first time, and it will remember it afterwards -- but something along these lines may be closer:
    (defun my-perl-run-file () (interactive) (let ((file (buffer-file-name))) (with-current-buffer (get-buffer-create "*perl-output*") (erase-buffer) (call-process "/usr/bin/perl" nil (current-buffer) t file) (display-buffer (current-buffer)))))
Re: Emacs: Submit a Perl Script
by FunkyMonk (Canon) on Dec 17, 2007 at 22:18 UTC
Re: Emacs: Submit a Perl Script
by jplindstrom (Monsignor) on Dec 18, 2007 at 01:01 UTC
    Good answers with cperl-mode, compile and friends.

    Another option is to use Devel::PerlySense's Run File command.

    It's similar in that it uses Emacs' compilation mode. It is different in that it's aware of things other than that particular source file, like from where you likely want to run the file, where used modules live, etc.

    It is currently more limited in some ways, e.g it doesn't take any command line parameters which I can imagine may be useful if you actually want to run .pl scripts rather than, let's say, plain .t files. But that's mostly because I haven't had the need yet (it is on the todo list however).

    (As an aside, if you're still using UltraEdit now and then, maybe you'll find -- shameless plug of very old program -- Perl Oasis useful.)


Re: Emacs: Submit a Perl Script
by mpettis (Beadle) on Dec 18, 2007 at 00:48 UTC
    All of the advice I've gotten so far is great, and I think/hope will be sufficient for me to get a toehold into doing this. Thanks to all again, mpettis
Re: Emacs: Submit a Perl Script
by stefan k (Curate) on Dec 19, 2007 at 08:39 UTC
    don't forget to mention the valuable M-x cperl-check-syntax which also depends on mode compile. Also very useful: M-x cperl-perldoc which is context sensitive.

    In case you want to pipe your buffer contents to an external perlprogram and have the output replace the sent content try to mark a region and go C-u M-! perlprogramm.

    To run your program you might also try M-x executable-interpret. I seem to have bound a key to that eons ago, but didn't use it. I will give it a try during the next days ;-)

    Regards... stefan k
    you begin bashing the string with a +42 regexp of confusion

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://657525]
Approved by Joost
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2017-09-20 10:07 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (234 votes). Check out past polls.