How to run Perl script in Linux?
Here you will find out:
- how to check whether you have Perl installed
- how to create a new text file
- how to run a Perl script
- when DiskInternals can help you
Are you ready? Let's read!
Learning Perl programming in Linux
If you’re interested in learning Perl programming, this article details the core information you need to get started. Normally, when a programmer is learning a new language, their first script will be the “Hello World” script. Thus, in Perl programming, you will need to learn how to print “Hello World,” first, before attempting other, more intricate scripts.
Check whether you have Perl installed
Before you can run Perl, it must be installed on your Linux system. You can check for Perl on your Linux system with this command in the terminal:
Perl –v
If Perl is already installed on your system, the above code will print the current version of Perl you have on the system. But, if Perl is not on your system, you’ll get an error response.
Visit the official Perl website to download and install Perl on Linux.
How to create a new text file
Perl scripts are saved with the extension .pl; although adding the extension to your script’s name is unnecessary, you should just know about it. You can write your Perl scripts in a text editor such as Notepad, Vi, TextEdit, Emacs, Ultra Edit, Textmate, etc. However, you should never write a Perl program using document editors such as MS Word, OneNote, OpenOffice Writer, etc.
To start writing your first Perl program, launch your text editor and type the following commands:
Save the Linux Perl script with any name of your choice. For example, you can save the file as “test.pl”.
How to run a Perl script
Now that you have written your first Perl script, the next step is to run the script. This will take you back to the terminal.
- Open a terminal and change the directory to where your Perl script is saved
- For DOS systems, type cd c:\perl\scripts
Then run:
This script will ask you to enter your name, and when you do so, hit the “Enter” key. Perl will call your name with this response.
Do you want to get files from Linux in Windows?
Let’s say you are working with a Windows PC and need to get some important files from your Linux partitions; how would you do that? Well, Windows won’t allow you to access Linux partitions, but with DiskInternals Linux Reader, you can easily access and get any file saved from your Linux partition. DiskInternals Linux Reader supports all Linux file systems and can read any Linux partition.
Also, DiskInternals Linux Reader features a user-friendly interface and displays all your Linux partitions just as Windows displays all your drives in its File Explorer page. DiskInternals Linux Reader software is available for free, and it works for both virtual machines and dual-boot setups.
Related articles
- How to Access Linux Ext2 or Ext3 on Windows
- Mount Linux Drive on Windows for Free
- Guide in Pictures
- A Bash Dirname Command
- Learn about Korn shell scripting
- Bash: how to split strings in Linux
- Here is everything you need to know about Bash for Windows
- How to Use Shell Script Sleep Command
- Linux: Sudo in Bash Scripts
- Use a Shell Script to Send an Email
- Learn about useful bash scripts
- Learn about systemd startup script
- Using /usr/bin/env command
- The disk you inserted was not readable by this computer error
- Shell script usage
- About a bash date command
- How to Access Ext4 from Windows
- How to Mount Ext4 on Windows for Free
- Bash Script: All You Need to Know
- An Algorithm: How to Create Bash While Loop
- Linux Shell: What You Need to Know at First
- 5 Basic Shell Script Examples for Your First Script
- Bash: How to Check if the File Does Not Exist
- Bash Time Command on Linux
- How to use bash get script directory in Linux
- How to Check Bash String Equality
- Bash: How to Loop Through Files in Directory
- 20 Examples of Bash Find Command
- Bash Cat Command in Examples
- Bash Script SSH: How to Use It
- Bash: A Script For User Input
- Linux ZSH: the basic you need to know
- Basic of Grep in Linux Shell Script
- Shell Script Cut: Basic You Need to Know
- Bash: How to Check if String Not Empty in Linux
- Hello World Script in Bash
- A Linux bin/bash Shell
- Linux: New Line in Shell Script
- Linux: Bash String Ends With
- Linux: Bash Printf Examples
- Linux: Bash First Line
- Linux: $0 in a Shell Script
- Linux: A Bash Startup Script
- Linux: Write a Shell Script
- Shell Script: Replace String in File
- A crontab service shell script
- A Bash Multiline Command
- Bash and sh: is there any difference
- Linux: A Bash Source Command
- A Bash to Loop through Lines in File
- Linux: A Bash Linter
- A Bash Nested Loop
- A Bash Test Command
- A Bash Status of Last Command
- Linux: A Bash Basename Command
- Using Bash to Write to a File
- About Bash Language
- Bash for Loop in One Line
- About chaining bash commands
- Learn about a bash error code
- Using a bash tee command
- About a bash export command
- Learn about a bash wait command
- Arch Linux install script
- About advanced bash scripting
- To run a shell script in Dockerfile
- About a bash UNTIL loop
- Learn about C shell script
- Whether bash waits for command to finish
- Using bash if 0
- Using && in an IF statement in bash
- If you want to run shell script in background
- Learn about SFTP in bash scripting
- Examples of using the Expect
- Copy command in shell scripts
- Install Oracle Database
- AWK in a Bash Script
- How to Use Linux Wait Command




