{"id":699,"date":"2020-10-20T17:21:01","date_gmt":"2020-10-20T17:21:01","guid":{"rendered":"https:\/\/linuxways.net\/?p=699"},"modified":"2020-11-13T20:52:00","modified_gmt":"2020-11-13T20:52:00","slug":"how-to-create-and-run-a-perl-script-in-ubuntu-20-04-lts","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-create-and-run-a-perl-script-in-ubuntu-20-04-lts\/","title":{"rendered":"How to create and run a Perl script in Ubuntu 20.04 LTS"},"content":{"rendered":"<p>Perl is abbreviated for Practical Extraction and Reporting Language that is a well-known and powerful language for String Processing and handling. It is a web scripting language that can be used along with different web frameworks and the latest technologies. Mostly the Perl used for server-side scripting but, it can also be used to front-end interface programming languages like HTML with the backend in the Database application. It is fast and robust so, it can interact with many other programming languages on different platforms.<\/p>\n<p>In this article, we will talk about the best steps to install Perl language and how we can create and run the Perl script through the command line on Ubuntu 20.04.<\/p>\n<h1><strong>Prerequisites<\/strong><\/h1>\n<p>You should have sudo access to run administrative commands on your system.<\/p>\n<h1><strong>Installation of Perl on Ubuntu 20.04<\/strong><\/h1>\n<p>We have implemented different steps in this article on the command line application \u2018Terminal\u2019. Before going to start the Perl installation steps in detail, open the terminal window. You can access this application by pressing \u2018Ctrl+Alt+t\u2019 or you can also open it from the application menu.<\/p>\n<p>Execute the following different steps to install Perl and run a Perl script on your Ubuntu system:<\/p>\n<h1><strong>Step 1: Update your system<\/strong><\/h1>\n<p>Before going to start the installation of Perl, it is recommended to update your system by typing the following command via terminal:<\/p>\n<pre>$ sudo apt update<\/pre>\n<p>The above command will download and install all available updates for your Ubuntu 20.04 apt repository.<\/p>\n<h1><strong>Step 2: Install Perl on Ubuntu 20.04<\/strong><\/h1>\n<p>On our system, Perl is already installed. But, if you don\u2019t have Perl installed on your system then, you can install it directly from the Ubuntu repository by typing the following command:<\/p>\n<pre>$ sudo apt install perl<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"283\" class=\"wp-image-700\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-350.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-350.png 731w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-350-300x116.png 300w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<p>The above command will automatically install the all required Perl packages and dependencies on your system.<\/p>\n<h1><strong>Step 3: Verify the Perl Installation<\/strong><\/h1>\n<p>Once the installation of Perl is completed, now you can verify the installation by using the following \u2018grep\u2019 command on your terminal:<\/p>\n<pre>$ apt list --installed | grep -i perl<\/pre>\n<p>The above command will find the all installed packages of Perl and list on the terminal window which you can see in the following snapshot:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"480\" class=\"wp-image-701\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-351.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-351.png 734w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-351-300x196.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<h1><strong>Step 4: Check Installed Perl Version<\/strong><\/h1>\n<p>If you want to know which Perl version is installed on your Ubuntu system then, by executing the following command you can check it:<\/p>\n<pre>$ perl -v<\/pre>\n<p>As you can see in the below-given screenshot that Perl version \u2018v5.30.0.\u2019 is installed our system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"732\" height=\"294\" class=\"wp-image-702\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-352.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-352.png 732w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-352-300x120.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/p>\n<h1><strong>Step 5: Run Your First Perl Script on Ubuntu 20.04<\/strong><\/h1>\n<p>Now, it\u2019s time to run your first Perl script on your system. To do this, create a simple text file in your favorite text editor and paste the following code into it:<\/p>\n<pre>#!\/usr\/bin\/perl\n\nuse warnings;\n\nprint(\"Hi, this is test script Hello world\\n\");<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"892\" height=\"153\" class=\"wp-image-703\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-353.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-353.png 892w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-353-300x51.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-353-768x132.png 768w\" sizes=\"auto, (max-width: 892px) 100vw, 892px\" \/><\/p>\n<p>Save the above file with named \u2018helloworld.pl\u2019. The file will be saved in your home directory by default. Run this file via the terminal by typing the below-mentioned command:<\/p>\n<pre>$ perl helloworld.pl<\/pre>\n<p>The following result will be shown on the terminal after running the above mentioned script:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"738\" height=\"71\" class=\"wp-image-704\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-354.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-354.png 738w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-354-300x29.png 300w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><\/p>\n<h1><strong>Step 6: Install Perl Sql module on Ubuntu 20.04<\/strong><\/h1>\n<p>You can install the MySQL module for Perl on your Ubuntu 20.04 system. To do this, follow the below apt command to install the Perl Mysql module:<\/p>\n<pre>$ sudo apt install libdbd-mysql-perl -y<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"628\" class=\"wp-image-705\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-355.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-355.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-355-300x259.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<p>The above mentioned command will install the necessary mysql&nbsp;Perl packages on your Ubuntu system.<\/p>\n<h1><strong>Conclusion<\/strong><\/h1>\n<p>In the above article, we have explained the installation of Perl and how to create and run Perl script using the command line on Ubuntu 20.04. We have also discussed how to configure necessary Perl modules on your system. Please let us know about your difficulties or queries related this article.<\/p>","protected":false},"excerpt":{"rendered":"<p>Perl is abbreviated for Practical Extraction and Reporting Language that is a well-known and powerful language for String Processing and handling. It is a web scripting language that&hellip;<\/p>","protected":false},"author":2,"featured_media":1572,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[18],"class_list":["post-699","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-perl-script"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=699"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/699\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/1572"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}