Run Perl in One-liner and Script files
Previously, we talk about the basics of Perl and you know how to run it in different Operating Systems.
However, if your program is short and you do not need to save the program. Is there any other choices?
Sure, in Perl you have two ways of running it. You can run Perl in script files as well as running it in One-liner.
Running Perl in script files
Running in script files, means you are running the ".pl" files. You should know how to do it.
If you are still new to Perl, know more from "What's Perl and why you should learn it?"
Running Perl in One-liner
Running Perl in One-liner means you are just typing one command to run the Perl script rather than saving the scripts in a ".pl" file.
Open console or in command mode, type the following command to try:
In Windows:
C:\Perl\bin\perl -w -e "Print \"Hello, World!\n\";"
Explanation:
In the above One-liners, "-w" means warnings on, "-e" means execute the scripts.
print "Hello, World!\n"; is the actual script to run.
Conclusion:
Running Perl programs in Script files is the common way to do it, however, you have another choice when you want to use Perl scripts to do some jobs in a faster way without opening text editor to create a new file.
Try One-liner and it is sometimes quite convenient and save your time.
Enjoy Perl, keep an eye on this section.









