Perl is not an interactive shell, though there are plenty of features for you to be able to
build an interactive shell using Perl.
When you type
perl on an interactive shell such as bash on Linux then, without a program file to run, it reads the standard input stream, which, by default, comes from the keyboard. At this stage it does not care if the commands are being read from a file or a keyboard. If you look at
perlsyn you will see that there is no 'up arrow' command in perl. The '^[[A' is a textual translation of what the terminal driver sends it.
Shells such as bash and ksh perform two functions, they are, like Perl, a scripting language, but they also provide an interactive interface. This is good because it enables you to do the kind of things you are trying, but it is bad because it has to compile each statement as you enter it. Shells are a compromise between these two needs. Use a text editor to enter your Perl program into a text file, starting with
#!/usr/bin/perl, save it into a directory that is in your $PATH, give it execute access with
chmod u+x and then run it as you would any other program.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.