Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Difference between a perl script & shell script

by Hue-Bond (Priest)
on Dec 19, 2005 at 15:49 UTC ( [id://517764]=note: print w/replies, xml ) Need Help??


in reply to Re: Difference between a perl script & shell script
in thread Difference between a perl script & shell script

Perl's interpreter isn't really interactive like that
$ perl print "Look ma, I'm interactive!\n"; __END__ Look ma, I'm interactive! $ _

--
David Serrano

Replies are listed 'Best First'.
Re^3: Difference between a perl script & shell script
by revdiablo (Prior) on Dec 19, 2005 at 18:12 UTC

    That's not interactive, that's taking the source code via STDIN. There's a difference, namely in that interactive means you run one command, get the return value. Run another, get another return value. This is commonly known as REPL, or a Read Eval Print Loop. You can make one in Perl:

    perl -le '@ret = eval and print "Returned [@ret]" while <STDIN>'

    But it's not quite as fully featured as most interactive shells.

      Have you tried perl -demo ???

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

Re^3: Difference between a perl script & shell script
by JohnMG (Beadle) on Dec 19, 2005 at 18:36 UTC

    Interesting. Didn't know you could do that. Thanks.

    A quick comparison of Perl, Python, and shell interactive modes:

    • Perl -- You type in the whole script, line by line, and you get the output only after all lines have been entered and after you've typed __END__ as the last line. A syntax error will dump you back to the command line.
    • shell -- you always get the output (if there is any) right after each line/command. View $? to see the return value of the last command that was run.
    • Python -- You get the output of statements as you run them, just like the shell. Also, it automatically prints out the value of the expression evaluated on the line you just typed.

    IMO, the Python shell is pretty darn interactive. The Perl shell might be nice for one-liners that take up more than one line ;), but it doesn't seem all that interactive to me.

      The python interactive environment is definitely nice.

      Term::ShellKit provides something along the same lines. I generally make do with perl -de1.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://517764]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-29 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found