How to Run Perl Scripts in Linux Command Line
文章推薦指數: 80 %
Learn to learn Perl scripts in Linux command line. Also learn a few tricks about running Perl commands without saving them in files.
Pleaseenteratleast3characters
0resultsfound
Tips
Commands
Tutorial
QuickTip
Docker
Explain
Aug23,2022
•
3minread
HowtoRunPerlscriptsinLinuxCommandLine
SagarSharma
TableofContents
CallthemancientbutPerlscriptsarestillagreatwayofscriptingautomationtasksforvarioussysadmintasks.IfyouarenewtoitandwonderinghowtorunPerlscriptsintheLinuxterminal,justusethiscommand:perlscript.plThiswillworkevenifthescriptfiledoesn'thavetheexecutepermission.Youmayalsorunitlikeabashscript:./script.plButforthattowork,thefilemusthavetheexecutepermissionandthescriptmustbeginwiththehashbang:#!/usr/bin/perlAslongasthesyntaxisrightandPerlinstalledonyoursystem,youshouldbeabletorunPerlscriptseasily.HowdoyouknowifPerlisinstalledonyoursystem?Usethiscommandandifyouseetheversiondetails,youshouldbegood.perl--versionCheckingifPerlisinstalledIfyoursystemthrowsanerrorlike"Perlcommandnotfound,"useyoursystem'spackagemanagertoinstallitfirst.ThereareotherwaysofusingPerlinLinux.YoucanwriteaPerlscriptdirectlyintheterminalandrunitimmediately,withoutevensavingit.Let'sseethingsinabitmoredetail.ExecutingPerlscriptsfromthefilesThisistherecommendedwaytocreateandexecutePerlscripts.YouhavethescriptssavedandyoucanusetheminanIDElikeEclipseifthescriptiscomplicatedorpartofalargerPerlproject.Perlfiledoesnotneedtohaveanyextension,buta".pl"extensionisgoodpractice.Createanewfileusingthetouchcommandlikethis:touchmy_file.plTherecentlycreatedfilewillbeempty,I'llbeusingNanoeditortomodifytheemptyfile.nanomy_file.plMysamplescriptlookslikethis:#!/usr/bin/perl
print"Enteryourname:";
$name=
延伸文章資訊
- 1Running Perl Scripts on Linux Systems
There are many ways to run Perl scripts on Linux: 1. Run the "perl" command with the Perl script ...
- 2How to Run Perl Scripts in Linux Command Line
Learn to learn Perl scripts in Linux command line. Also learn a few tricks about running Perl com...
- 37 of the most useful Perl command line options
7 of the most useful Perl command line options · -v to get the Perl version · -V to get compiler ...
- 4Perl執行shell命令的幾種方式及其區別 - 程式人生
There are many ways to execute external commands from Perl. The most commons are: system function...
- 5Perl - Introduction to the Command Line - FLOSS Manuals (en)
Perl is a programming language that can be used to perform tasks that would be difficult or cumbe...