Highlights All Snippets Top 100 Snippets Librarians gbCodeLib
By Language VB6 JavaScript Perl HTML SQL Java DOS
The first category of consists of mini-tutorials for the language, followed by categories of source code snippets. Click on a title to see the source code.
The source code is organized into the following categories:
_tutorials 01 Overview 02 Sample Code 03 IDE 04 Syntax 05 Data types / variables 06 Operators 07 Boolean Logic 08 Strings 09 Arrays 10 Associative array 11 Conditional flow 12 Subroutines 13 Scope 14 Files/folders 15 System functions 16 Graphics 17 Sound 18 Date-Time 19 Math 20 Printing 21 Error handling 25 Databases 26 Event handlers 27 Using Perl on the web (CGI) 28 Distribution 29 Command Summary 30 Top 100 31 Regular expressions 32 Common mistakes 33 Regular expressions 34 Modules arrays Does an array contain an element Extract unique elements of an array look up a hash by value modify each element of an array #2 print lines r through s of an array print only the first n elements of an array to a file process an entire hash randomly extract from an array until all are gone select random element from an array shuffle an array randomly cgi CGI script for web page with complete form CGI script for web page with embedded variables CGI script to return a file from the server inside an HTML file CGI script to return existing page CGI script to return web page with no data Get variables from QUERY_STRING conditional looping Everlasting loop For loop loop through a file loop through a hash loop through a hash array #2 loop through an array loop through array using FOR #2 loop through array using FOREACH with $_ short circuiting while loop email sendmail formatting print formatting print samples math Find primes perform operation on series of integers print print an array to a file print to more than one file at once sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
arrays Does an array contain an element Extract unique elements of an array look up a hash by value modify each element of an array #2 print lines r through s of an array print only the first n elements of an array to a file process an entire hash randomly extract from an array until all are gone select random element from an array shuffle an array randomly cgi CGI script for web page with complete form CGI script for web page with embedded variables CGI script to return a file from the server inside an HTML file CGI script to return existing page CGI script to return web page with no data Get variables from QUERY_STRING conditional looping Everlasting loop For loop loop through a file loop through a hash loop through a hash array #2 loop through an array loop through array using FOR #2 loop through array using FOREACH with $_ short circuiting while loop email sendmail formatting print formatting print samples math Find primes perform operation on series of integers print print an array to a file print to more than one file at once sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
cgi CGI script for web page with complete form CGI script for web page with embedded variables CGI script to return a file from the server inside an HTML file CGI script to return existing page CGI script to return web page with no data Get variables from QUERY_STRING conditional looping Everlasting loop For loop loop through a file loop through a hash loop through a hash array #2 loop through an array loop through array using FOR #2 loop through array using FOREACH with $_ short circuiting while loop email sendmail formatting print formatting print samples math Find primes perform operation on series of integers print print an array to a file print to more than one file at once sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
conditional looping Everlasting loop For loop loop through a file loop through a hash loop through a hash array #2 loop through an array loop through array using FOR #2 loop through array using FOREACH with $_ short circuiting while loop email sendmail formatting print formatting print samples math Find primes perform operation on series of integers print print an array to a file print to more than one file at once sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
email sendmail formatting print formatting print samples math Find primes perform operation on series of integers print print an array to a file print to more than one file at once sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
formatting print formatting print samples math Find primes perform operation on series of integers print print an array to a file print to more than one file at once sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
math Find primes perform operation on series of integers print print an array to a file print to more than one file at once sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
print print an array to a file print to more than one file at once sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
sort sort array numerically sort hash by a key sort on several fields strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
strings Code data for reading as records List of all files then separate file from path remove newline character from end of string return last 5 characters in a string trim a string #2 syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
syntax swap two variables system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
system info CGI script to display all environmental variables text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
text file Count the number of lines in a file Delete last line of a file read a file and write it to a second file #2 read a random line from a file read a text file into a scalar read a text file into an array then print it read a text file one line at a time select a random line from a file selectively save part of file time print current time time handling
time print current time time handling