I'm not familiar with how EditPlus relates to taking input in a Perl script.
The following script will prompt for and take user input via STDIN, place it in a variable named $input, strip away the trailing newline, and will print what the user typed in, to STDOUT.
#!/usr/bin/perl
use strict;
use warnings;
print "Enter your input:\n";
my $input = <STDIN>;
chomp $input;
print "You typed: $input\n";
| [reply] [d/l] |
How do I get user input? I tried using <STDIN> in EditPlus, and it crashes every time!
That's not very helpful. Whatever EditPlus is, it's not part
of the Perl distribution, so that's hardly relevant. What
you need to do is 1) show what you did, 2) tell what you
expect it to do and 3) tell what it did. That will maximize
your chances in getting a useful answer.
Abigail
| [reply] |
If I'm not mistaken EditPlus runs on Windows only, but I don't know how stable it is. So, you may want to run your scripts from a DOS prompt instead of EditPlus.
Check out the Tutorials section. Read up on "How to Ask Questions" and "Getting Started with Perl".
Also, you definitely want to pick up a copy of "Learning Perl 3rd Edition". It's a must for getting started.
| [reply] |
| [reply] |
You might want to take a look at Term::ReadKey. I use that and it works like a charm for me.
| [reply] |
I tried using <STDIN> in EditPlus, and it crashes every time!
EditPlus is a text editor, right? And you're trying to run perl as a tool, executing your script in a hidden manner, and capturing its output into an editor window? I don't know what terminology EditPlus uses, but if I'm right, you should know what I mean: it's as if running a compiler from within the editor.
Well, I guess that Perl doesn't actually crash, but that it hangs — waiting for input, which it can't get because you can't enter it.
I can't think of a quick solution right now, except for not doing it this way, and instead, run the script from the command line (also known as the "DOS prompt"). For non-interactive scripts, running a script from within the editor is just fine.
Getting user input in another manner, via a GUI, is another, neat solution, however, it requires a lot of work, and I don't think a module for doing an "inputbox" (like a messagebox with a text widget — as available in VBscript, and Javascript too, IIRC) is available. Yet. You probably wouldn't want to use it anyway because you won't install modules </sneer>
| [reply] |
| [reply] |
Thanks folks. I appreciate all your comments, and they helped. As for EditPlus....BAH! It shall be removed from my box post haste. Thanks again,
Senior PartyMarty (ole!) | [reply] |