Toggle navigation
FreeKB
About
Walkthroughs
Linux Commands
Sign In
FreeKB - Perl articles
Perl articles
Arrays
Getting Started with Arrays
Append value to the beginning of an array (unshift)
Append value to the end of an array (push)
Count values in an array
Create array over SSH
Remove all values from array (undef)
Remove empty lines from array
Remove first line from array (splice)
Remove values beginning of array (shift)
Remove values end of array (pop)
Remove values from array (splice)
Replace values in array (map)
Sort array
Store files directories in array (glob)
Built in Perl commands
%ENV environment special hash
Escape special characters using quotemeta (\Q \E)
eval function
Lower case (lc)
Random number generator (rand)
Update the first character in a string to be upper case (ucfirst)
Upper case (uc)
Variable contains (=~) or does not contain (!~)
Wrap text (Text::Wrap)
Command Line Options and Flags
Getting Started with command line options and flags
Count
Count characters in a string (length)
Count lines in a file ($.)
Data::Dumper
Getting Started with Data::Dumper
Date Time
Date and time using strftime
Date and time using Time::Piece
Directories
List directories
File::Basename
File::Basename module
File::Touch
Getting Started with File::Touch
Files
Previous, current, and next line in a file (seek, tell)
Transfer a file
Files - TXT / DOC / CSV
Determine if file contains a string of data
Read a file (<)
Read and write to the same file
Replace values in a file
Write to a file (> and >>)
Files - XLS
Append or replace data in an Excel spreadsheet (Spreadsheet::ParseExcel)
Read an Excel 95-2003 spreadsheet (xls)
Write to an Excel 95-2003 spreadsheet (xls)
Hashes
Array of Hashes
Count keys and values in a hash
Hash (append values)
Hash (create empty hash)
Hash (determine if hash is defined)
Hash (determine if hash key is defined)
Hash (grep keys)
Hash (lock_keys lock_values)
Hash (multidimensional hash)
Hash (remove values)
Hash (sort keys)
Hash Array (append key value pairs)
Hash Array (append keys)
Hash Array (append values)
Hash Array (create empty array)
Hash Array (determine if hash array defined)
Hash Array (remove values)
loop through hash keys
loop through hash values
print hash values
if elsif else statements
Getting Started with if elsif else statements
Determine if a directory is empty
Install
Install a module (cpan)
Install Perl on Linux
JSON
Getting Started with JSON::Parse
JSON Modification of a read-only value
JSON::Parse reason Not Found error Object Not Found
Logger
Getting Started with Log::Log4perl Logger
Loops
foreach loops
Loop through a file until line match
loop through a range of items in an array
Moving onto next value in a loop (next)
while loop
Math
Addition (+)
Convert hexadecimal to decimal
Division (/)
Multiplication (*)
Subtraction (-)
Sum of integers in a file
Modules
Create your own module
Determine if a module is installed
Other
Native operating system command (`backticks`)
Prompt a user for input
Scientific notation with Microsoft Excel
Printing output
Bold text (Term::ANSIColor)
Display text on the console (print and say)
Regular Expressions (regex)
( and ) characters
Append leading zeros to numbers
carriage returns (\r ^M)
Dealing with Microsoft Word curly fancy smart quotes
Do something end of line
Do something every nth line in a file
Do something range of lines
Flatten lists (merge similar lines)
Match last occurrence of a line in a file
new lines (\n)
Regular expression delimiter
Replace text in a file (-pi -e =~)
Trailing forward slash
Using grep
whitespace (\s)
SFTP
Getting Started with Net::SFTP
Spliting string
Cut a string into pieces (substr)
Split fields at delimiter
SQL database
Connect to a SQL database
SSH
Getting Started with Net::OpenSSH
Getting Started with Net::SSH:Perl
Local and remote variables over SSH
SSH run command on a remote host
Subroutines
Getting Started with Subroutines
Identical subroutine names (package, namespace)
Pass values to a subroutine (@_ and $_ and shift)
return in a subroutine
Troubleshooting
Resolve "Host key for has changed"
Variables / Scalars
Getting Started with scalars and variables
Append values to a variable (.=)
Determine if a variable is defined
Determine if a variable is empty or null
Global and lexical variables (my)
Replace values in a variable (=~)
XML::Simple
Getting Started with XML::Simple
Data::Dumper and XML::Simple
XML::Simple Arrays
XML::Simple ForceArray
XML::Simple Ignore Attributes
XML::Simple looping through hash keys
XML::Simple looping through keys
XML::Simple looping through keys that contain attributes
XML::Simple Printing Attributes
XML::Simple printing keys (XMLin)
XML::Simple printing values (XMLin)