Perl examples (example source code) Organized by topic






Network /

Client 6DNS 1
FTP 5gethostbyaddr 2
gethostbyname 2gethostent 1
getnetent 1getprotobyname 1
getprotobynumber 1getprotoent 1
getservbyname 1getservbyport 2
getservent 1hostname 1
HTML Parser 2HTTP 7
IP Address 2LWP 2
Mail 7News 1
Ping 2Server 10
sockaddr_un 1Socket 14
TCP 9Telnet 1
UDP 4Web Server 1

Regular Expression /

Anchors 17bracket 4
Case 1Character Class 11
Digit 13Escape 7
Frequency 5Greedy 10
grep 9Group 1
Index 7Loop 5
Metacharacters 9metasymbols 4
modifier 18parentheses 3
Pattern matching 30split 9
substitution 20tr 8
translation 4

CGI /

Content Type 3Cookie 13
Environment Variables 17File Upload 3
Form 43HTML Table 3
HTML 21Image 2
Page 7URL 4

Win32 /

Clipboard 2EventLog 2
Excel 3File 5
FormatMessage 1NetAdmin 4
NetResource 2ODBC 3
Process 2Registry 4
Service 3Shortcut 1
Sound 1Win32 7
Word 2

XML /

SAX 10

GUI /

Action 4Buildin Bitmap 10
Button 7Canvas 7
Checkbox 6Color Dialog 2
Control Attributes 8Dialog 1
File Dialog 2Font 4
Grid 4Label 3
Layout 13Listbox 5
MainWindow 8Menu 11
Radiobutton 4Scale 4
Scrollbar 1Statusbar 1
Text 17

Subroutine /

BEGIN END 1Closure 3
Context 4Local 6
my 11Nested 4
Parameter 22prototype 3
Recursive 7Return 19
Subroutine Call 8Subroutine Definition 13
Subroutine Reference 4wantarray 2

System Functions /

abs 1acos 1
alarm 1atan2 2
Benchmark 2Class 1
Complex 2cos 1
Cwd 1Data 6
defined 1die 3
English 3Env 2
eval 4exec 2
exit 2exp 1
ExtUtils 1File 3
fork 5getgrent 4
getlogin 1Getopt 14
getpgrp 1getprotoent 1
getpwent 3getpwnam 4
is_windows 1localtime 1
map 2Math 3
pack 5PGP 1
POSIX 1qualify 2
qualify_to_ref 1rad2deg 1
rand 10Safe 1
scalar 3setlocale 1
Shell 5sin 3
sleep 2sqrt 1
srand 1system 10
tan 2Term 6
Test 1Text 5
Time 1undef 1
unpack 5User 5
vec 1wait 2
waitpid 3

Data Type /

binary 4Casting 9
Data Type 7date time 14
float 12hex 10
int 20oct 8
ref 10Reference 26
wantarray 1

Array /

Array Assignmengt 10Array Definition 16
Array Hash 2Array Index 22
Array Item 13Array Length 11
Array Loop 11Array Output 9
Array Reference 10Array Scalar 10
Array Search 2Array Value 13
chop chomp 1delete 1
exists 1join 5
map 1Multidimensional Arrays 19
pop 6push 8
range 2reverse 10
shift 6Slice 10
sort 17splice 17
stack 1unshift 4

Class /

Attributes 2Class Definition 3
Constructor 3Destructor 1
Methods 2Object 1

File /

binmode 5CDROM 1
chdir 3chmod 5
chown 1close 2
closedir 3Cwd 1
eof 1File Copy 3
file handle 16File Output 7
file read 24file seek 10
file test 37file write 16
File 12FileHandle 1
fileparse 1flock 2
getc 4getcwd 1
glob 7IO 8
link 1LOCK 1
mkdir 6Open file 30
opendir 4PIPE 3
readdir 5readlink 3
rename 4rmdir 3
rmtree 2seekdir 1
select 3stat 10
Storable 2symlink 2
tell 3telldir 3
truncate 2umask 1
unlink 3

Report /

Alignment 2Field 11
Footer 1Format 9
Header 5Number 1
Output 8Pagination 1
Special Variables 4Variable 5

Database /

AnyDBM 4DBI 9
DBM 8insert 4
MySql 12ODBC 6
OLE ADO 3select 8
Transaction 1update 3

Hash /

delete 6each 5
exists 5Hash Assignment 4
Hash Collections 6Hash Definition 16
Hash Loop 7Hash Output 5
Hash Reference 11Hash Value 8
join 1key 6
keys 6lock_value 1
map 2reverse 4
slice 2sort 10
value 8values 2

Language Basics /

Arithmetic Operators 35Assignment Operators 13
Bitwise Operator 15Boolean Operators 11
Code Block 12Command Line 23
Comments 6Comparison Operators 26
Conditional Operators 3defined undef 2
Module 4Package 15
Perl Command 16Perl Script 17
perldoc 2PPM 4
Pragmas 6Print 40
require 1Scalar Reference 5
Scalar 21Special Variables 128
strict 10Variable Scope 7
Variable 17

Statement /

continue 3Do Until 2
Do While 5For 25
Foreach 36goto 2
If 35Last 12
Next 8Range 20
Redo 5switch 3
unless 8Until 13
While 28

String /

Case 6chop chomp 13
chr 3Compare 9
Concatenate 8crypt 3
DATA 1Escape 10
Here Document 10index 5
interpolation 5join 9
lc 1lcfirst 1
length 5Multiline 3
ord 4pos 1
printf 44Quotations 57
quotemeta 1Repetition 8
Replace 3Reverse 2
rindex 1Split 8
sprintf 13String 15
strstr 1substr 11
uc 1ucfirst 3
Unicode 7