❮ Index
❯
TOC: Perl Programming
- Preface
- First steps
- Scalars
- Scalars intro
- Scalar values
- undef
- Numbers - integers, real or floating-point
- Strings
- Scalar variables (use my)
- Sigils and variables
- Common error messages
- Greeting with a name, Variable interpolation
- User Input
- chomp
- Numerical Operators
- Autoincrement
- String Operators
- String - Number conversion
- Conditional statements: if
- Syntax of if statement
- Comparison operators
- Compare values - examples
- undef, the initial value and defined
- Boolean expressions (logical operators)
- Boolean values: TRUE and FALSE
- Your Salary is in Danger - Short-Circuit
- Exercise: Rectangular
- Exercise: Rectangular prompt
- Exercise: Rectangular warn
- Exercise: Concatenation
- Exercises: Simple Calculator
- Solution: Rectangular
- Solution: Rectangular prompt
- Solution: Rectangular warn
- Solution: Concatenation
- Solution: Simple Calculator
- Solution: Simple Calculator (using eval)
- String functions (length, lc, uc, index)
- String functions (index, rindex)
- String functions (substr)
- Strings - Double quoted
- Strings - Single quoted
- Scope of variables
- Scope of variables - 2
- Scope of variables - 3
- Scope of variables - 4
- Scope of variables - 5
- Random numbers
- Here documents - double quotes
- Here documents - single quotes
- Exercise: Number Guessing game
- Solution: Number Guessing game
- Files
- die, warn, exit
- while loop
- Loop controls: next, last
- Opening file for reading
- Opening a file
- Opening a file - error handling
- Opening a missing file
- Read one line from a file
- Process an entire file line by line (while, cat)
- Write to a file
- Sum of numbers in a file
- Analyze the Apache log file
- Encoding and UTF-8
- Open files in the old way
- Binary mode
- Reading from file, read, eof
- tell, seek
- truncate
- Exercise: Add more statistics
- Exercise: Write report to file
- Exercise: Analyze Apache - number of successful hits
- Solution: Add more statistics
- Solution: Write report to file
- Solution: Analyze Apache - number of successful hits
- Lists and Arrays
- Lists and Arrays intro
- List Literals, list ranges
- List Assignment
- loop over elements of list with foreach
- Create an Array, loop over with foreach
- Array Assignment
- Debugging an array
- foreach loop on numbers
- Array index (menu)
- Load Module
- Command line parameters
- Process command line parameters, use modules
- Module documentation
- process CSV file
- process csv file (short version)
- One-liner sum numbers in CSV file
- process csv file using Text::CSV
- process csv file using Text::CSV
- Join
- Labels
- Exercise: Make the color selector user friendly
- Exercise: improve the color selector
- Exercise: Improve the Number Guessing game
- Solution: improved color selector
- Solution: Improve the Number Guessing game
- Advanced Arrays
- The year 19100
- SCALAR and LIST Context
- Context Sensitivity
- Filehandle in scalar and list context
- slurp mode
- File::Slurp
- Diamond operator
- pop, push
- push example
- stack (pop, push) Reverse Polish Calculator
- shift, unshift
- queue (shift, push)
- shift
- reverse
- Sort
- Ternary operator
- Count digits
- Exercise: Color selector
- Exercise: sort numbers
- Exercise: sort mixed string
- Exercise: sort mixed string 2
- Solution: color selector files
- Solution: sort numbers
- Solution: sort mixed strings
- Solution: sort mixed strings
- List::Util
- Advanced: Multi dimensional array
- Functions and Subroutines
- Why to use subroutines?
- Subroutines
- Variable number of parameters
- Recursive subroutines: factorial
- Recursive subroutines: Fibonacci
- Sort using a function
- Return a list
- Return several elements
- Error handling with eval - files
- Error handling with eval - two calls
- Exercise: Subroutines
- Exercise: Number guessing in sub
- Solution: Number guessing in sub
- Hashes
- What is a hash?
- Uses of hashes
- Creating hashes
- Create hash from an array
- Hash in scalar context
- Fetching data from hash
- exists, delete hash element
- Multi dimensional hashes
- Count words
- Exercise: Parse HTTP values
- Exercise: Improve the color selector
- Exercise: Display scores
- Exercise: Analyze Apache log file
- Exercise: Parse variable width fields
- Solution: Parse HTTP values
- Solution: Improve the color selector
- Solution: Display scores
- Solution: Analyze Apache log file
- Solution: Parse variable width fields
- Regular Expressions I
- What are regexes good for ?
- Examples
- Where can I use it ?
- Introduction to Regexes
- grep
- Tools
- Find a string in a file
- Regex Examples: single character
- Regex Examples: more characters
- Regex Examples dot .
- Regex Examples (character class)
- Regex Examples (^ in character class)
- Optional character
- Regex Examples quantifiers
- Quantifiers
- Quantifiers on character classes
- Exercises: Regular expressions
- Solutions: Regular expressions
- Regular Expressions II
- Regular Expressions
- Regexp::Common
- Options and modifiers
- /i Case sensitivity
- Matching quotes
- /s single line
- /m multiple lines
- /x enable white spaces and comments
- Substitute
- Global substitute
- Greedy quantifiers
- minimal match
- Replace spaces
- Replace string in assembly code
- Full example of previous
- split with regular expression
- Fixing dates
- Exercise: split CGI
- Exercise: basename/dirname
- Exercise: Sort SNMP numbers
- Exercise: parse hours log file and give report
- Exercise: Parse ini file
- Exercise: parse perl file
- Solution: Split CGI
- Solution: filename/dirname
- Solution: Sort SNMP numbers
- Solution: parse hours log file and give report
- Solution: Parse ini file
- Solution: parse perl file
- Regular Expressions Cheat sheet
- Shell to Perl
- Shell and Perl intro
- File test or -X operators
- Running External Programs
- Open pipe for reading
- Open pipe for writing
- Pager
- sendmail.pl
- UNIX commands from the inside
- File globbing (wildcards)
- Rename files
- Directory handles
- File::HomeDir
- More UNIX commands implemented in modules
- File::Spec
- Change Copyright text in every source file in a directory hierarchy
- Exercise: Tree
- Exercise: Check for UID 0
- Exercise: CPU load
- Exercise: MANIFEST file
- Solutions: Tree
- Solutions: Check for UID 0
- Solution: CPU load
- Solution: MANIFEST file
- Using Perl modules, using CPAN
- Using modules exporting functions
- Using Object Oriented modules
- Selecting Module to use
- Some interesting CPAN Modules: DateTime
- Days passed
- Some interesting CPAN Modules: Databases
- Some interesting CPAN Modules: Web
- Some interesting CPAN Modules: common file format
- Some interesting CPAN Modules
- Installing modules
- Installing modules from the os vendor
- Using CPAN.pm
- Configure CPAN.pm
- Installing modules manually
- Installing modules manually using Build.PL
- On Windows
- Changing @INC
- Changing @INC - Relative PATH
- local::lib
- CPAN.pm
- Installing modules on ActivePerl
- CPAN::Reporter
- Exercise: setup local::lib
- Exercise: Module installation
- Exercise: Read Excel file
- Solution: Module installation
- Solution: Read Excel file
- Applications
- Simple uses of Perl
- Create Unix user account
- Reporting file system diskspace usage (df)
- Reporting diskspace usage on the mail server
- A du like script
- Send files by e-mail
- Read Excel file
- Process file with fixed width records
- Process file with multiline records
- Process multi field csv file
- Fetch web page
- Generate web page
- Parse XML file
- Database access using DBI and DBD::SQLite
- Net::LDAP
- Tie::File
- One-liners
- Extra slides
- List all defined variables
- Perl internal variables
- What is Perl ?
- What does Perl stand for ?
- Scripting language ?
- Is Perl Interpreted or Compiled Language
- Why use Perl ?
- What is it good for ?
- Its strengths
- Redirection by the user
- for loop
- ASCII table
- default variable $_
- Return values
- UNIX file system, hard links symbolic links
- stat, lstat
- Compare values
- Bitwise Operations
- bitwise examples
- Filename creation based on date
- Debugging prints
- Where is perl installed on your system ?
- Send e-mail
- XML using Perl
- XML sample data
- XML Definitions
- XML processing modes
- XML::Simple
- XML::Simple dumped
- XML::Simple processing
- XML::Parser
- XML::Parser tree
- XML::Parser tree results
- XML::Parser
- XML::LibXML
- XML::XPath
- XML::Twig
- XML::Writer
- XML::Dumper
- Exercise: parse glade.xml
- DTD validation
- Specialized XML modules
- Resources
- Parsing HTML File
- Appendix
- Perl References
- Uses cases for references
- References
- Array References
- Hash References
- Scalar references
- Subroutine references
- Passing values to a function
- Add two (or more) arrays
- Add two arrays
- Array References
- Process arrays without copying
- Scope of variables
- Reference counting
- More Reference Counting
- Process arrays without copying even the return values
- Debugging (pretty printing)
- Change values in a reference
- Exercise: double numbers
- Exercise: Add many arrays
- Exercise: Function to compare two hashes
- Solution: Double numbers
- Solution: Add many arrays
- Solution: Add many arrays
- Solution: Function to compare two hashes
- Anonymous Arrays
- Array of Arrays
- Array of Arrays (AoA)
- Many dimensional arrays
- Anonymous hashes
- Hash of Hashes (HoH)
- More complex data structures
- Memory leak with cross references
- Memory leak with cross references - weaken
- Read CSV file
- Exercise: read in an ini file
- Exercise: improve the csv reader
- Solution: Read ini file
- Solution: improve the csv reader
- autovivification
- Scalar references in Getopt::Long
- Anonymous subroutines
- Uses of Subroutine references
- Exercise: DNA Sequence Analyzer
- Solution: DNA Sequence Analyzer
- Exercise: DNA Sequence Analyzer with callback
- Solution: DNA Sequence Analyzer with callback
- Exercise: DNA Sequence Analyzer with shortcut
- Solution: DNA Sequence Analyzer with shortcut
- Dispatch Table
- Dispatch Table using symbolic references
- The ref() function
- Copy a data structure
- Deep copy
- Deep copy - Storable dclone
- Serialization
- Data::Dumper
- Data::Dumper both dump and restore
- Storable
- Storable in memory freezing
- YAML
- YAML in one file
- JSON in one file
- Main uses of references
- Exercise: save ini and csv as YAML
- Exercise: Create a cache for NetSlow
- Exercise: create a function that generates numbers multipliers
- Solution: save ini and csv as YAML
- Solution: Create a cache for NetSlow
- Solution: NetSlow cache with timeout
- Resources
- Processes and signals
- Advanced slides
- Always use strict and warnings
- Avoid warnings
- Turn off warnings selectively and in a small scope
- Catch and log warnings
- splain and use diagnostics
- Fatal warnings
- Logging Exceptions
- Always open files in the new way
- Array slices
- Array slices on the fly
- Hash slices
- Hash slices in assignment
- splice
- LIST and SCALAR context
- wantarray
- wantarray example
- Slow sorting
- Speed up sorting
- Schwartzian transformation
- Compilation phases: BEGIN, CHECK, INIT, END
- AUTOLOAD
- Static variable
- Exercise: create counter
- Solution: create counter
- Saved variable: local
- autodie
- Modern::Perl
- Perl::Critic
- Perl::Tidy
- caller
- Log::Dispatch
- Log::Log4perl easy
- Exercise: Log::Dispatch
- Solution Log::Dispatch
- Functional Programming in Perl
- Programming Paradigms
- Functional programming
- grep
- grep to filter files based on modification date
- Imitating the Unix/Linux grep command in Perl
- map
- Use map to filter values
- Map to add more elements
- Use map to filter and enrich
- Create a hash from an array using map
- Unique values
- Unique values - improved
- Unique values using grep
- Uniq with List::MoreUtils
- Closures
- Advanced Features in 5.10
- New features in 5.12
- Perl Libraries and Modules
- Lack of code reuse
- Perl library (perl4 style)
- Problems with Libraries
- Prefix everything with unique name
- Namespaces
- Solution with namespace
- Modules
- Packages, @INC and Namespace hierarchy
- use, require and import
- Export - Import
- Restrict the import
- On demand Import
- Importing
- Modules - behind the scene
- Tools for packaging and distribution
- Packaging modules
- Makefile.PL of ExtUtils::MakeMaker
- Makefile.PL of Module::Install
- Build.PL of Module::Build
- Changes and README
- MANIFEST and MANIFEST.SKIP
- A script
- A module
- Packaging with Makefile.PL
- Packaging with Build.PL
- A test file
- Writing Tests
- Exercises: Multiply numbers
- Solution: Multiply numbers
- Overview
- Error Handling
- Introduction to Moose
- Moose Constructor
- Test Moose Constructor
- Moose Attribute
- Test Moose Attribute
- Moose Attribute Type
- Test Moose Attribute Type
- Moose Attribute Type class
- Test Moose Attribute Type class
- Moose Attribute - create your own subtype
- Test Moose Attribute - create your own subtype
- Moose Attribute - coercion
- Test Moose Attribute - coercion
- Moose Enumeration
- Moose Attributes Overview
- Inheritance
- Testing Inheritance
- MooseX::StrictConstructor
- Testing Strict attributes
- Encapsulation
- Class data
- Special actions during object construction
- Singleton in Moose
- Destructor in Moose
- More about files
- Running subprocess
- Perl Tk
- Perl Tk
- Perl Tk Plain Window
- Perl Tk Label
- Perl Tk Button
- Perl Tk Entry (visible and hidden for secrets)
- Perl Tk Text editor
- Perl Tk Menu
- Perl Tk Keyboard binding
- Perl Tk Any Key binding
- Perl Tk Mouse button and movement bindings
- Perl Tk Mouse events, coordinates
- Perl Tk Checkbutton (Checkbox)
- Perl Tk Radiobutton
- Perl Tk Listbox
- Perl Tk Dialog
- Perl Tk DialogBox with custom buttons and widgets
- Perl Tk Notepad (Simple editor)
- Perl Tk Message
- Perl Tk with HTML
- Perl Tk Dialog Box with HTML
- Perl Tk Browse Entry (ComboBox)
- Perl Tk Option Menu
- Perl Tk Table
- Perl Tk Menu Button
- Prima
- wxPerl - wxWidgets for Perl
- Microsoft Windows
- PSGI
- Testing Demo for Perl
- Parallel processing
- Types of problems
- Types of solutions
- Tasks
- Measurements on 32 core
- Measurements on 4 core
- The Hardware
- Installations
- Fork
- Fork with functions details
- Fork random and seed
- Fork without functions
- Fork details
- Fork many
- Parent process ID
- pstree
- htop
- Active non-blocking waiting with waitpid
- Non-blocking waiting with waitpid - multiple forks
- Non-blocking waiting, rerun on failure
- Functions to be speed up
- Counter process
- Forked counter process
- Prepare CSV files
- Process CSV files
- Use Parallel::ForkManager
- Return values using Parallel::ForkManager
- Forked process CSV files
- HTTP GET
- Forked HTTP requests
- Exercise: Process Excel files
- Exercise: Web crawler
- MCE - Many-Core Engine
- MCE - map running in parallel
- MCE - map with init
- other modules
- Database Testing
- Database access using Perl DBI
- Advanced Database access using Perl DBI
- Database access using DBIx::Class
- Microsoft Windows GUI Testing
- GUI testing
- Keyboard and mouse movements
- Win32::GuiTest
- Win32::GUIRobot
- Calculator
- Launch the application
- Locale
- Close the application
- Using the Keyboard
- Check the children
- Fetch content of a control
- Window location
- Move the mouse
- Move the cursor around the edges
- Close the window by a mouse click
- Calculate using the mouse
- The full calc.pl example
- Installing Win32::GuiTest
- Tools
- Internet Explorer
- X-Windows
- X11
- X11 Tools
- X11::GUITest
- LDTP - Linux Desktop Testing Project
- Manual steps
- X11: Launch the application
- Let's see the coordinates
- Where is this top left corner ?
- And let's see the rest of the coordinates
- Smooth on the edges
- Closing the window
- Placing the cursor on one of the buttons and clicking on it
- So let's do all the calculations
- Fetch the list of Child Windows
- Locate the Child Windows
- Using the keyboard
- Separate the keystrokes
- Full solution for xcalc
- Appendixes
- Other
- Read CSV file as array of hashes
- Sort array using sort and sort_by
- Range iterator
- Benchmark
- Bubble sort
- Insert sort
- Merge sort
- Quicksort
- Timsort
- Traverse directory tree
- Traverse directory tree with call back
- Linear search in unorderd array
- Binary search in sorted array
- Convert curl command with -F to LWP::UserAgent
- Modify time anomality in two files