{"id":3058,"date":"2020-12-30T18:54:55","date_gmt":"2020-12-30T18:54:55","guid":{"rendered":"https:\/\/linuxways.net\/?p=3058"},"modified":"2020-12-30T18:54:58","modified_gmt":"2020-12-30T18:54:58","slug":"how-to-create-and-run-a-perl-script-in-linux-mint-20","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/mint\/how-to-create-and-run-a-perl-script-in-linux-mint-20\/","title":{"rendered":"How to Create and Run a Perl Script in Linux Mint 20"},"content":{"rendered":"<h2>Introduction:<\/h2>\n<p>Perl is an efficient high-level programming language that was released in 2000 and has been extensively used since then. It stands for Practical Extraction and Reporting Language. The feature of Perl that makes it extremely versatile is that it can be used across multiple platforms including Linux. In today\u2019s article, we would be sharing with you the method of creating and running a Perl script in Linux Mint 20.<\/p>\n<h2>Some Pre-Processing:<\/h2>\n<p>Before we take a look at the procedure of creating and running a Perl script in Linux Mint 20, we would like to install Perl on our Linux Mint 20 system with the help of the following command:<\/p>\n<pre><strong>sudo apt-get install perl<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"448\" height=\"24\" class=\"wp-image-3059\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-503.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-503.png 448w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-503-300x16.png 300w\" sizes=\"auto, (max-width: 448px) 100vw, 448px\" \/><\/strong><\/p>\n<p>In our case, we already had Perl installed on our Linux Mint 20 system. That is why we have received the messages shown in the image below. However, if Perl would not have been installed on our system, then running this command would have immediately installed it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"549\" height=\"151\" class=\"wp-image-3060\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-504.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-504.png 549w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-504-300x83.png 300w\" sizes=\"auto, (max-width: 549px) 100vw, 549px\" \/><\/p>\n<p>Now we would like to check out the version of Perl installed on our system by running the following command:<\/p>\n<pre><strong>perl --version<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"359\" height=\"26\" class=\"wp-image-3061\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-505.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-505.png 359w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-505-300x22.png 300w\" sizes=\"auto, (max-width: 359px) 100vw, 359px\" \/><\/p>\n<p>The version of Perl installed on our Linux Mint 20 system is shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"645\" height=\"287\" class=\"wp-image-3062\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-506.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-506.png 645w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-506-300x133.png 300w\" sizes=\"auto, (max-width: 645px) 100vw, 645px\" \/><\/p>\n<p>After this, we also need to ensure that the respective interpreter for Perl is also installed on our Linux Mint 20 system. We can do this by running the following command:<\/p>\n<pre><strong>which perl<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"333\" height=\"28\" class=\"wp-image-3063\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-507.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-507.png 333w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-507-300x25.png 300w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/strong><\/p>\n<p>The output of this command will reveal the path to the binary file of the Perl interpreter as shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"330\" height=\"59\" class=\"wp-image-3064\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-508.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-508.png 330w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-508-300x54.png 300w\" sizes=\"auto, (max-width: 330px) 100vw, 330px\" \/><\/p>\n<p>You can also check out the path to the source file and man pages of the Perl interpreter with the help of the following command:<\/p>\n<pre><strong>whereis perl<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"346\" height=\"26\" class=\"wp-image-3065\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-509.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-509.png 346w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-509-300x23.png 300w\" sizes=\"auto, (max-width: 346px) 100vw, 346px\" \/><\/strong><\/p>\n<p>The output of this command will guarantee the presence of the Perl interpreter on our Linux Mint 20 system as shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"94\" class=\"wp-image-3066\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-510.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-510.png 649w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-510-300x43.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/p>\n<p>Now we are all set to write and run our first Perl script in Linux Mint 20.<\/p>\n<h2>Method of Creating a Perl Script in Linux Mint 20:<\/h2>\n<p>For creating a sample Perl script in Linux Mint 20, we will run the following command:<\/p>\n<pre><strong>sudo nano Sample.pl<\/strong><\/pre>\n<p>Here, you can replace Sample with any name of your choice that you want to keep for your first Perl script. We have named it as MyPerlScript.pl as shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"25\" class=\"wp-image-3067\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-511.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-511.png 450w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-511-300x17.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/p>\n<p>This command will open an empty Perl file with the nano editor. We have written a simple Perl script to display a message on the terminal as shown in the following image. Here, the first line of the script is mandatory and it is written to indicate that the said file is a Perl file. Then we have simply written the \u201cprint\u201d command followed by a sample message which will be displayed on the terminal. After that, we have closed this file once it was saved.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"646\" height=\"68\" class=\"wp-image-3068\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-512.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-512.png 646w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-512-300x32.png 300w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/p>\n<h2>Method of Running a Perl Script in Linux Mint 20:<\/h2>\n<p>After creating our first Perl script in Linux Mint 20, now it is the time to execute it with the following command:<\/p>\n<pre><strong>perl Sample.pl<\/strong><\/pre>\n<p>Here, you can replace Sample with the name of your particular first Perl script. The name of our first Perl script was MyPerlScript.pl as shown in the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"411\" height=\"26\" class=\"wp-image-3069\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-513.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-513.png 411w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-513-300x19.png 300w\" sizes=\"auto, (max-width: 411px) 100vw, 411px\" \/><\/p>\n<p>After running this command, the output of our created Perl script will be displayed on the terminal as shown in the following image:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"447\" height=\"58\" class=\"wp-image-3070\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-514.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-514.png 447w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/12\/word-image-514-300x39.png 300w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/p>\n<h2>Conclusion:<\/h2>\n<p>This article focused on the creation and execution of a Perl script in Linux Mint 20. Moreover, if Perl is not installed on your system already, then we have even shared with you the method of installing it on your system and also ensuring if its interpreter exists there or not.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction: Perl is an efficient high-level programming language that was released in 2000 and has been extensively used since then. It stands for Practical Extraction and Reporting Language.&hellip;<\/p>","protected":false},"author":3,"featured_media":3072,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[129,18],"class_list":["post-3058","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mint","tag-linux-mint-20","tag-perl-script"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/3058","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=3058"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/3058\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/3072"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=3058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=3058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=3058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}