Perl examples (example source code) Organized by topic





Network /

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

Regular Expression /

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

CGI /

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

Win32 /

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

XML /

SAX 10

GUI /

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

Subroutine /

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

System Functions /

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

Data Type /

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

Array /

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

Class /

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

File /

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

Report /

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

Database /

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

Hash /

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

Language Basics /

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

Statement /

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

String /

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