FreeKB - Perl (Scripting) articles
Perl (Scripting) articles

ArraysGetting Started with ArraysAppend element to the beginning of an array (unshift)Append element to the end of an array (push)Count elements in an arrayCreate array over SSHDuplicate elements in an arrayPrint last value in an array in PerlRemove all elements from array (undef)Remove duplicate values from an arrayRemove element beginning of array (shift)Remove element from array (splice)Remove empty lines from arrayRemove first element from array (splice)Remove last element from an array (pop) Replace element in array (map)Sort arrayStore files directories in array (glob)Built in Perl commands%ENV environment special hashEscape special characters using quotemeta (\Q \E)eval functionLower case (lc)Random number generator (rand)scriptname $0Update 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 FlagsGetting Started with command line options and flagsCountCount characters in a string (length)Count lines in a file ($.)curlcurl HTTPS (LWP::UserAgent, LWP::Protocol::https)Data::DumperGetting Started with Data::DumperDate TimeDate and time using localtimeDate and time using strftimeDate and Time using Time::Piece (timepiece)epoch date and timeDirectoriesList directoriesEmailNet::SMTP (email)Send email using Email::Sender and Email::MIMEFile::BasenameFile::Basename moduleFile::TouchGetting Started with File::TouchFilesPrevious, current, and next line in a file (seek, tell)Transfer a fileFiles - TXT / DOC / CSVDetermine if file contains a string of dataOpen file for reading (<)Open file for writing appending overwriting (> and >>)Read and write to the same fileReplace values in a fileFiles - XLSAppend or replace data in an Excel spreadsheet (Spreadsheet::ParseExcel)Read an Excel 95-2003 spreadsheet (xls) Write to an Excel 95-2003 spreadsheet (xls) HashesHash (append key value pairs)Hash (append values multidimensional)Hash (append values)Hash (count keys and values)Hash (define 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 keys)Hash (remove values multidimensional)Hash (remove values)Hash (sort keys)Hash Array (append key value pairs multidimensional)Hash Array (append key value pairs) Hash Array (append keys)Hash Array (append values multidimensional)Hash Array (append values)Hash Array (count keys multidimensional)Hash Array (count keys)Hash Array (count values)Hash Array (create empty array multidimensional)Hash Array (create empty array)Hash Array (define hash)Hash Array (determine if hash array defined)Hash Array (determine if hash array is empty)Hash Array (remove all elements from a hash array)Hash Array (remove values multidimensional)Hash Array (remove values)Hash Reference (append values multidimensional)Hash Reference (append values)Hash Reference (create an empty reference hash)Hash Reference (define reference hash)Hash Reference (determine if hash key is defined)Hash Reference (determine if reference hash is defined)Hash Reference (multidimensional reference hash)loop hash (keys multidimensional)loop hash (keys)loop hash (values)loop hash array (key value pairs)loop hash array (keys multidimensional)loop hash array (keys)loop hash array (values multidimensional )loop hash array (values)print hash valuesif elsif else statementsGetting Started with if elsif else statementsDetermine if a directory is emptyInstallInstall Perl on LinuxJSONGetting Started with JSON::CreateGetting Started with JSON::ParseJSON Modification of a read-only valueJSON::Parse reason Not Found error Object Not FoundLoggerGetting Started with Log::Log4perl LoggerLoopsBreak out of a loop (last)foreach loopsLoop through a file until line matchloop through a range of items in an arrayMoving onto next value in a loop (next)while loopMathAddition and Increment (+)Convert base 16 hexadecimal to decimalDivision (/)Multiplication (*)Subtraction (-)Sum of integers in a fileModulesCreate your own moduleDetermine if a module is installedInstall a module using cpanInstall a module using cpanmOtherNative operating system command (`backticks`)Prompt a user for input (stdin)Scientific notation with Microsoft ExcelPrinting outputBold text (Term::ANSIColor)Display text on the console (print and say)Regular Expressions (regex)( and ) charactersAppend leading zeros to numberscarriage returns (\r ^M)Dealing with Microsoft Word curly fancy smart quotesDo something beginning of line (^)Do something end of line ($)Do something every nth line in a fileDo something range of linesEscape literal dollar sign $Flatten lists (merge similar lines)match first all last occurrence of a patternMatch last occurrence of a line in a filenew lines (\n)Regular expression delimiterReplace text in a file (-pi -e =~)Trailing forward slashUsing grepwhitespace (\s)REST API (curl)Getting Started with the LWP::UserAgent REST API module (curl)basic authentication username password with the LWP::UserAgent REST API module (curl)GET request with the LWP::UserAgent REST API module (curl)headers with the LWP::UserAgent REST API module (curl)insecure SSL certificates with the LWP::UserAgent REST API module (curl)POST data with the LWP::UserAgent REST API module (curl)ReturnBreak out of a subroutine (return)return a hashreturn a stringreturn a variablereturn an arraySFTPGetting Started with Net::SFTPSpliting stringCut a string into pieces (substr)Split fields at delimiterSQL databaseConnect to a SQL databaseSSHGetting Started with Net::OpenSSHGetting Started with Net::SSH:PerlLocal and remote variables over SSHPublic key authentication with Net::SSH:PerlSubroutinesGetting Started with SubroutinesIdentical subroutine names (package, namespace)Pass values to a subroutine (@_ and $_ and shift)TroubleshootingResolve "Can't locate in @INC" in PerlResolve "Host key for has changed"Resolve "JSON Error Empty input parsing initial state"Resolve "Reference found where even-sized list expected"Variables / ScalarsGetting Started with scalars and variablesAppend values to a variable (.=)Determine if a variable is definedDetermine if a variable is empty or nullGlobal and lexical variables (my)Replace values in a variable (=~)XML::SimpleGetting Started with XML::SimpleData::Dumper and XML::SimpleXML::Simple ArraysXML::Simple ForceArrayXML::Simple Ignore Attributes XML::Simple looping through hash keysXML::Simple looping through keysXML::Simple looping through keys that contain attributesXML::Simple output XML (XMLout)XML::Simple Printing AttributesXML::Simple printing keys (XMLin)XML::Simple printing values (XMLin)XML::Simple store XML in a variable (XMLin)XML::TwigXML::Twig change tag (set_tag)XML::Twig change value (set_text)XML::Twig loop through tags (first_child children)XML::Twig output to a fileXML::Twig parse XMLXML::Twig print values (text)

Web design by yours truely - me, myself, and I   |   |