Richard's Perl Step 50
Practical Examples



- Most of the time, when we forget some programming stuff, we don't consult books, we learn from our own past programs.


Passing values to a function, and return value

01_function.txt - Passing values to a function (subroutine)

02_function.txt - Return value from a function (subroutine)


Pattern matching (html document)

03_pattern.txt - match pattern involving multiple lines (treat multiple line as a single line)

04_pattern.txt - assertion: continue from last match occurred. (good for loop)

12_pattern.txt - extract multiple patterns, and assign them to multiple variables


Array Printing

05_array.txt - fast print array

06_array.txt - print 2-D array (actually list of lists), also show length of array


String operations

07_string.txt - Get rid of spaces in front / at the back of string

08_string.txt - convert string to number

09_string.txt - substring operation

10_string.txt - remove character(s) from string, uppercase string


Directory / File Names

11_directory.txt - scan directory and files in directory


Time

13_time.txt - GMT time, local time, time in seconds

14_time_hi.txt - time in high resolution