Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Perl and Emacs

by loosid (Initiate)
on Jul 25, 2000 at 00:00 UTC ( #24165=perlquestion: print w/replies, xml ) Need Help??

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

I am trying to configure E-Macs to use Perl but for some reason it won't read in user input. For example, the code: print "what's your name? "; $name = <stdin>; chomp $name; print "hello, $name!\n"; has the following output in emacs: what's your name? hello, ! This script works on a command prompt, but not in emacs. Any help would be much appreciated. Thanks, Matt

Replies are listed 'Best First'.
RE: Perl and Emacs
by BlueLines (Hermit) on Jul 25, 2000 at 01:05 UTC
    In most .emacs setups, M-! (ie executing a shell command) invokes a non-interactive shell. usually this is because you use this to run non-interactive tasks, ie no stdin , just a command (like make). What you want to do is open a shell in a new frame, not run a shell command. I'm not if there's a default key binding for this, but since i use xemacs i can just click on the "Tools" menu. Although i find a real shell to be much nicer than an emacs one :-)

Re: Perl and Emacs
by fundflow (Chaplain) on Jul 25, 2000 at 00:11 UTC
    I'm not an emacs expert but the shells inside emacs seem to "steal" the new lines, so the redirection that you hope for (keyboard ---> program's STDIN) doesn't work. This one works for me though:
    echo "MYNAME" | perl -e ' ...your program here...'
Re: Perl and Emacs
by loosid (Initiate) on Jul 25, 2000 at 00:42 UTC
    Can I change the input method in Emacs to allow perl to work with this format?
      This is more of an Emacs topic.

      I found some info here You need to check/ask the comp.emacs.* newsgroups for more info

      Why do you want to run perl through emacs? Just curious.
RE: Perl and Emacs
by BlueLines (Hermit) on Jul 25, 2000 at 23:12 UTC
    Also, here's what the shell entry looks like in my .emacs file:
    ;;; ;;; Shell-mode ;;; ---------- (setf sh-shell-file "/bin/sh")

Re: Perl and Emacs
by loosid (Initiate) on Jul 25, 2000 at 22:22 UTC
    Is there another product that has a shell setup so I can both write and execute?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://24165]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2022-01-18 02:32 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (52 votes). Check out past polls.