When I type perl in any command prompt (with Perl installed on the system of course) nothing really happens. What is the point of using perl at the command prompt? Unlike the python, lua, and ruby commands it seems to do nothing.
If it does do something, what is it and how do you use it?
The
perlcommand with no arguments compiles and runs any Perl code it sees on its standard input; it doesn’t give you an interactive prompt as some other interpreters do.A good way to try out individual Perl commands is to invoke the Perl debugger:
The switches are:
-d: Invoke the Perl debugger-w: Enable warnings-e 1: Execute0as a Perl script (it does nothing, but leaves you in the interactive debugger).And as Jack Maney said in his comment, you should read the documentation (
perldoc perlrunshould give you the same information locally).But keep in mind that the primary purpose of the
perlcommand is to execute Perl scripts. Perl can be used interactively, and one-liners such as:(which prints the current time in seconds since 1970) can be very useful, but that’s not its main use. Normally you’d have a script with
(or equivalent) as the first line.