SlideShare a Scribd company logo
Perl in the Command Line
-c: Test Compiling -c : causes Perl to check the syntax of the program and then exit without executing it.
It will execute  BEGIN ,  UNITCHECK ,  CHECK , and  use  blocks, because these are considered as occurring outside the execution of your program.
It will not execute  INIT  and  END  blocks.
-w, -W and -X: Warnings -w : This turns on warnings that Perl will then give you if it finds any of a number of problems in your code. The  -w  option has been replaced by the  use warnings  pragma.
-W:  Enables all warnings regardless of  no warnings  or  $^W .
-X:  Disables all warnings regardless of  use warnings  or  $^W .
$> perldoc perllexwarn
-d: Debugging -d : This option puts you into the Perl debugger.
-d:DProf : executes the program using the  Devel::DProf  profiler, combined with  dprofpp  may help you to find where is your program slow.
$> perldoc perldebtut $> perldoc perldebug
-e: eval -e:  allows you to define code to be executed by the compiler.  $> perl -e 'print "Hello World"' "Hello World" program in the shell. -E : like -e, but enables all optional features
-M: module Import -M : This option imports a module.  -Mmodule  is the same has  use module .
$> perl –Mdiagnostics script.pl Get better error message.
perl -MLWP::Simple -e 'print get($ARGV[0]), "\n"' http://perl.com Better as an alias.

More Related Content

PPT
Customising py py
PDF
Command Line Arguments with Getopt::Long
PDF
Zeppelin Helium: Spell
PPT
C++ programming
PDF
Command line arguments that make you smile
PDF
clap: Command line argument parser for Pharo
PPTX
PHP 5.3
PPT
Gift-VT Tools Development Overview
Customising py py
Command Line Arguments with Getopt::Long
Zeppelin Helium: Spell
C++ programming
Command line arguments that make you smile
clap: Command line argument parser for Pharo
PHP 5.3
Gift-VT Tools Development Overview

What's hot (20)

ODP
New Stuff In Php 5.3
PDF
Compiladoresemulador
PPTX
Design patterns as power of programing
PPTX
Bioinformatics p4-io v2013-wim_vancriekinge
PPT
Perl Modules
PPTX
Python Programming Essentials - M27 - Logging module
DOCX
Looping statements
PPTX
Python Programming Essentials - M35 - Iterators & Generators
PPTX
Closures
PDF
Python Imports
PDF
Buffer overflow tutorial
PDF
Gore: Go REPL
PPTX
PHP 5.6 New and Deprecated Features
PPT
02 Php Vars Op Control Etc
PPT
Cell processor lab
ODP
Bash Programming
PDF
KEY
Prepare for PHP Test Fest 2009
DOCX
Perl 20tips
PPTX
Lesson 2 starting output
New Stuff In Php 5.3
Compiladoresemulador
Design patterns as power of programing
Bioinformatics p4-io v2013-wim_vancriekinge
Perl Modules
Python Programming Essentials - M27 - Logging module
Looping statements
Python Programming Essentials - M35 - Iterators & Generators
Closures
Python Imports
Buffer overflow tutorial
Gore: Go REPL
PHP 5.6 New and Deprecated Features
02 Php Vars Op Control Etc
Cell processor lab
Bash Programming
Prepare for PHP Test Fest 2009
Perl 20tips
Lesson 2 starting output
Ad

Similar to Perl In The Command Line (20)

PPT
You Can Do It! Start Using Perl to Handle Your Voyager Needs
PPT
LPW: Beginners Perl
ODP
Introduction to Perl - Day 1
PPT
CGI With Object Oriented Perl
ODP
Perl - laziness, impatience, hubris, and one liners
PPT
Bioinformatica 27-10-2011-p4-files
ODP
Introduction to Perl
PPT
Bioinformatica 29-09-2011-p1-introduction
PDF
Yapc::NA::2009 - Command Line Perl
ODP
Perl one-liners
PPTX
Lecture 3 Perl & FreeBSD administration
PDF
Perl.predefined.variables
PDF
System Programming and Administration
PPT
Perl one liners
PDF
IO Streams, Files and Directories
PDF
WEB PROGRAMMING UNIT VI BY BHAVSINGH MALOTH
PPT
Perl Presentation
ODP
Beginning Perl
PDF
Barely Legal Xxx Perl Presentation
PDF
newperl5
You Can Do It! Start Using Perl to Handle Your Voyager Needs
LPW: Beginners Perl
Introduction to Perl - Day 1
CGI With Object Oriented Perl
Perl - laziness, impatience, hubris, and one liners
Bioinformatica 27-10-2011-p4-files
Introduction to Perl
Bioinformatica 29-09-2011-p1-introduction
Yapc::NA::2009 - Command Line Perl
Perl one-liners
Lecture 3 Perl & FreeBSD administration
Perl.predefined.variables
System Programming and Administration
Perl one liners
IO Streams, Files and Directories
WEB PROGRAMMING UNIT VI BY BHAVSINGH MALOTH
Perl Presentation
Beginning Perl
Barely Legal Xxx Perl Presentation
newperl5
Ad

More from Marcos Rebelo (6)

PDF
Store stream data on Data Lake
PDF
Coordinating external data importer services using AWS step functions
PDF
Mojolicious
ODP
ODP
Modern Perl
ODP
Perl Introduction
Store stream data on Data Lake
Coordinating external data importer services using AWS step functions
Mojolicious
Modern Perl
Perl Introduction

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
MIND Revenue Release Quarter 2 2025 Press Release
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Empathic Computing: Creating Shared Understanding
MIND Revenue Release Quarter 2 2025 Press Release
The AUB Centre for AI in Media Proposal.docx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Weekly Chronicles - August'25 Week I
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
sap open course for s4hana steps from ECC to s4
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?

Perl In The Command Line

  • 1. Perl in the Command Line
  • 2. -c: Test Compiling -c : causes Perl to check the syntax of the program and then exit without executing it.
  • 3. It will execute BEGIN , UNITCHECK , CHECK , and use blocks, because these are considered as occurring outside the execution of your program.
  • 4. It will not execute INIT and END blocks.
  • 5. -w, -W and -X: Warnings -w : This turns on warnings that Perl will then give you if it finds any of a number of problems in your code. The -w option has been replaced by the use warnings pragma.
  • 6. -W: Enables all warnings regardless of no warnings or $^W .
  • 7. -X: Disables all warnings regardless of use warnings or $^W .
  • 9. -d: Debugging -d : This option puts you into the Perl debugger.
  • 10. -d:DProf : executes the program using the Devel::DProf profiler, combined with dprofpp may help you to find where is your program slow.
  • 11. $> perldoc perldebtut $> perldoc perldebug
  • 12. -e: eval -e: allows you to define code to be executed by the compiler. $> perl -e 'print "Hello World"' "Hello World" program in the shell. -E : like -e, but enables all optional features
  • 13. -M: module Import -M : This option imports a module. -Mmodule is the same has use module .
  • 14. $> perl –Mdiagnostics script.pl Get better error message.
  • 15. perl -MLWP::Simple -e 'print get($ARGV[0]), "\n"' http://perl.com Better as an alias.
  • 16. -n: Looping -n : Perl assumes the following loop around your program: LINE: while (<>) { # Your code }
  • 17. -n: Looping The command $> perl -ne 'print &quot;$. - $_&quot;' in.txt Would become LINE: while (<>) { print &quot;$. - $_&quot; } This code prints each line of the file together with the current line number.
  • 18. -p: Looping with print -p : Perl assumes the following loop around your program: LINE: while (<>) { # your code goes here } continue { print or die &quot;-p destination: $!\n&quot;; } This uses a continue block on a while loop to ensure that the print statement is always called.
  • 19. -p: Looping with print The -n example $> perl -ne 's/PHP/Perl/g; print' in.txt
  • 20. or the simpler $> perl -pe ' s/PHP/Perl/g ' in.txt
  • 21. It's very common to see command line programs that use Unix I/O redirection like this: $> perl -pe 's/PHP/Perl/g' in.txt > out.txt
  • 22. -i: edit in place $> perl -i -pe 's/PHP/Perl/g' in.txt Substitute every PHP occurence by Perl
  • 23. -i[extension] : edit in place. Case extension exists the original file is renamed, otherwise the file is overwitten.
  • 24. If the extension doesn't contain a * , then it is appended to the end of the current filename. If the extension does contain one or more * characters, then each * is replaced with the current filename.
  • 25. -l: Line-ending processing -l[octnum] : Automatic line-ending processing.
  • 26. It assigns $\ to have the value of octnum . Without octnum, $\ will be assigned to $/ .
  • 27. After chomp() everything on input
  • 28. Adds $\ (the output record separator) to each print
  • 29. -a and -F: Autosplitting -a: Splits the $_ whith a space while (<>) { @F = split(' '); # your code }
  • 30. -F: choses a diferent separator
  • 31. perl -F, -ane 'print join &quot;\t&quot;, @F' data.csv converts a csv into a tsv. Not really true but enough for example propose.
  • 33. Q&A