1. Down Downlo load ad perl perl from from http://www.perl.com/ 2. What is is Pe Perl? Perl, which stands for "Practical Extraction and Report Language", was written by Larry Wall. Its a great language for doing data manipulation tasks. Its fast, portable, and accessible. If you toss a bunch of monkeys into a roomful of typewriters, the chances of them accidentally producing the complete works of Shakespeare are effectively nil. The chances of them producing a working Perl program, however, are actually good. -NICHOLAS PETRELEY, Computerworld JUN 03, 2002 3. File File Ass Assoc ocia iati tion on In windows XP the association of a .pl file needs to be something like: "D:\Projects\tools\i386\win32\bin\perl.exe" "%1" %*
This is done in Explorer/View/Folder Options/File Types/Perl/open/Edit... 4. Some Some small small progra programs ms to learn learn perl by by exampl example: e: 1. Hell HelloW oWor orld ld.p .pll 2. - Dem Demon onst stra rate tes, s, "#" is a comment, the "print" statement, "\n" is the linefeed character. 3. #progr #program am HelloWo HelloWorld rld.pl .pl 4. print print "Hello "Hello World World!\n !\n"; ";
5. Hell HelloW oWor orld ld2. 2.pl pl 6. - Dem Demon onst stra rate tes: s: declaring a string variable on the fly printing a variable 7. #program #program HelloWor HelloWorld2. ld2.pl pl 8. $name $name = "Sarah "Sarah"; "; 9. print print "Hello "Hello $name $name!\n !\n"; ";
10. HelloW HelloWorld orld3.pl 3.pl 11. - Demonstra Demonstrates tes:: Interactively reading a string from the user the chomp() function 12. 13. 13.
#program He HelloWorld3.pl # this this dem demon onst stra rate tes s how how to read read fro from m the the user user and and use use the the chomp() function 14. 14. prin print t "Wha "What t is your name? ame?"; "; 15. $name = ; 16. 16. chom chomp( p($n $nam ame) e); ; # get get rid rid of the the carr carria iage ge retu return rn 17. print "Hello $name!\n";
18. HelloW HelloWorld orld4.pl 4.pl 19. - Demonstra Demonstrates tes:: the equal operator, "eq", for strings if-else clause 20. #program He HelloWorld4.pl 21. # this this demo demonst nstrat rates es the the equa equal l oper operato ator, r, "eq", "eq", for string strings s and and if-else clause 22. 22. print rint "What What is your our name name?" ?"; ; 23. $name = ; 24. 24. chom chomp( p($n $nam ame) e); ; # get get rid rid of the the carr carria iage ge retu return rn 25. if($name eq "Tex")
26. 27. 28. 29. 30. 31. 32.
{ print "Howdy $name!\n"; } else { print "Hello $name!\n"; }
33. PrintA PrintArgs. rgs.pl pl 34. - Demonstra Demonstrates tes:: Reading arguments from the command line Using the standard argument array, @ARGV The for loop 35. #program PrintArgs.pl 36. 36. # to to pri print nt all all the the argu argume ment nts s pas passe sed: d: 37. $numberOfArgs = @ARGV; 38. print print "The "The number number of argume arguments nts passed passed was $numbe $numberOf rOfArg Args s \n"; 39. 39. for( for($i $i=0 =0;$ ;$i i < $num $numbe berO rOfA fArg rgs s ; $i++ $i++) ) 40. { 41. 41. prin print t "arg "argv[ v[$i $i] ] = $ARG $ARGV[ V[$i $i]\ ]\n" n"; ; 42. }
43. cat. cat.pl pl 44. - Demonstra Demonstrates tes:: Reading from a file 45. 45. 46. 47. 48. 49. 50. 51. 52. 53.
#pro #progr gram am cat. cat.pl pl, , a tiny tiny prog progra ram m to to pri print nt a fil file. e. open(M open(MYFI YFILE, LE,$AR $ARGV GV[0] [0]) ) || || die die "Cann "Cannot ot open open file file \"$A \"$ARGV RGV[0] [0]\"" \""; ; while($line = ) { print "${line}"; } close(MYFILE);
54. WriteT WriteToFil oFile.pl e.pl 55. - Demonstra Demonstrates tes:: Writing to a file 56. #progr #program am WriteT WriteToF oFile ile.pl .pl, , a tiny tiny prog program ram to write write stuff stuff to a file. 57. 57. # "OU "OUTF TFIL ILE" E" is the the nam name e of of the the file file hand handle le 58. 58. open open(O (OUT UTFI FILE LE," ,">t >tes est. t.da dat" t") ) || || die die "Can "Canno not t ope open n file \"test.dat\""; 59. for($i=0; $i < 10; $i++) 60. { 61. 61. prin print t OUTF OUTFIL ILE E " line ine $i\n $i\n"; "; 62. } 63. close(OUTFILE); 64. 64. prin print t "Fin "Finis ishe hed d writ writin ing g to \"te \"test st.d .dat at\" \""; ";
65. paste paste.pl .pl 66. - Demonstra Demonstrates tes:: Checking for the right number of arguments Opening multiple files exit statement 67. #progr #program am paste. paste.pl, pl, a tiny tiny progra program m to paste paste the lines lines of one file onto another. 68. 68. # ie, ie, appe append nd to line line1 1 of of fil file1 e1 with with line line1 1 of of fil file2 e2 69. 69. if( if( @AR @ARGV GV < 2) 2) # is is les less s tha than n two two argu argume ment nts s 70. { 71. 71. prin print t "usa "usage ge: : past paste. e.pl pl file filena name me1 1 file filena name me2" 2"; ; exit exit 0; 72. } 73. 73. # "FI "FIRS RSTF TFIL ILE" E" is the the nam name e of of the the file file hand handle le
74. 74.
open open(F (FIR IRST STFI FILE LE,$ ,$AR ARGV GV[0 [0]) ]) || die die "Ca "Cann nnot ot open open file \"$ARGV[0]\""; 75. 75. open open(S (SEC ECON ONDF DFIL ILE, E,$A $ARG RGV[ V[1] 1]) ) || || die die "Can "Canno not t ope open n file \"$ARGV[1]\""; 76. 76. whil while( e($l $lin ine1 e1 = ) >) 77. { 78. $line2 = ; 79. 79. chom chomp( p($l $lin ine1 e1); ); # remo remove ves s the the CR/L CR/Lin ineF eFee eed d at the the end end 80. 80. prin print t "${l "${lin ine e1}${ 1}${li line ne2} 2}"; "; 81. } 82. close(FIRSTFILE); 83. close(SECONDFILE);
84. cut. cut.pl pl 85. - Demonstra Demonstrates tes:: Merging contents of files 86. of 87. 88. 89. 0; 90. 91. 92. 93. 94. 95. 96. 96. 97.
#progr #program am cut.pl cut.pl, , a tiny tiny progra program m to print print only only certai certain n column columns s a file if( @ARGV < 3) { print print "usage "usage: : cut.pl cut.pl filena filename me StartC StartColu olumn mn Length Length"; "; exit exit } $Start $StartCol Column umn = $ARGV $ARGV[1] [1]; ; #needs #needs more more error error checki checking ng here.. here... . $Length = $ARGV[2]; open(M open(MYFI YFILE, LE,$AR $ARGV GV[0] [0]) ) || || die die "Cann "Cannot ot open open file file \"$A \"$ARGV RGV[0] [0]\"" \""; ; while($line = ) { prin print t subs substr tr($ ($li line ne,$ ,$St Star artC tCol olum umnn-1, 1,$L $Len engt gth) h)." ."\n \n"; "; }
98. List of variable variable type type prefixes prefixes Variable Type Character Prefix
Scaler
$
Array
@
Hash
%
Subroutine
&
99. List of special characters characters Char Charac acte terr
Meani eaning ng
\n
newline
\"
double quote
\r
carriage Return
\t
tab
1 00 .
the substitution operator
The 'g' means 'global', all instances on the line s/OldString/NewString/g
or to do case insensitive use the 'i' modifier: s/OldString/NewString/ig
101. 101.
Repl Replac aceS eStr trin ing. g.pl pl usi using ng the the sub subst stit itut utio ion n oper operat ator or,, s/Ol s/OldS dStr trin ing/ g/Ne NewS wStr trin ing/ g/g g
102. 102. #pro #progr gram am Repl Replac aceS eStr trin ing. g.pl pl 103. if( @ARGV < 2) 104. { 105. 105. print print "usage "usage: : Replac ReplaceSt eStrin ring.p g.pl l filen filename ame OldStr OldString ing NewString\n"; 106. print print " example: example: perl ReplaceS ReplaceStrin tring.pl g.pl intelliq intelliquest uest.txt .txt "; 107. 107. print print "Intel "IntelliQ liQues uest t Kantar Kantar > kantar kantar.tx .txt\n t\n"; "; 108. exit 0; 109. } 110. 110. $Old $OldSt Stri ring ng = $AR $ARGV GV[1 [1]; ]; 111. 111. $New $NewSt Stri ring ng = $AR $ARGV GV[2 [2]; ]; 112. open(MYF open(MYFILE, ILE,$ARG $ARGV[0] V[0]) ) || || die die "Canno "Cannot t open open file \"$ARGV[ \"$ARGV[0]\" 0]\""; "; 113. 113. whil while( e($l $lin ine e = <
119. 119.
Repl eplace al all st strings ngs in in a file fro from m the com command line
Just remember p i e perl -p -i -e 's/oldstring/newstring/g' textfile.txt
1 20 . Search.pl 1 21 . - Demonstrates: the matching operator, =~ the index() function to find substrings in strings 122. #program #program Search.p Search.pl, l, example example of the matching matching operator operator, , =~ 123. if( @ARGV < 2) 124. { 125. 125. print print "usage "usage: : Search Search.pl .pl filena filename me Search SearchStr String ing\n" \n"; ; 126. 126. print print " exampl example: e: Search Search.pl .pl iq.txt iq.txt the \n"; \n"; 127. exit 0; 128. } 129. $SearchS $SearchStrin tring g = $ARGV[1] $ARGV[1]; ; #needs #needs more error error checking checking here... here... 130. open(MYF open(MYFILE, ILE,$ARG $ARGV[0] V[0]) ) || || die die "Canno "Cannot t open open file \"$ARGV[ \"$ARGV[0]\" 0]\""; "; 131. $i=1; 132. 132. whil while( e($l $lin ine e = ) >) 133. { 134. 134. if( $line $line =~ /$Sear /$SearchS chStri tring/ ng/i i ) #does #does $line $line contai contain n $SearchString? 135. 135. # /i mean means s to igno ignore re case case 136. { 137. 137. prin print t STDO STDOUT UT "$i: "$i: $lin $line" e"; ; 138. 138. $Start $StartCol Column umn = index( index($li $line, ne,$Se $Sear archS chStri tring) ng)+1; +1; 139. 139. print print " (\"$Se (\"$Searc archSt hStrin ring\" g\" starts starts in column column $StartColumn)\n"; 140. } 141. $i++; 142. }
1 43 . 1 44 .
ColumnSearch.pl - Demonstrates:
145. #program #program ColumnSe ColumnSearch arch.pl, .pl, shows shows a string string only if in certain certain columns 146. if( @ARGV < 4) 147. {
148. 148. print print "usage "usage: : Column ColumnSea Search rch.pl .pl filena filename me Search SearchStr String ing StartColumn EndColumn\n"; 149. 149. print print " exampl example: e: Column ColumnSea Search rch.pl .pl sample sample.ps .pst t 6 20 20\n"; 20\n"; 150. exit 0; 151. } 152. 152. $Sea $Searc rchS hStr trin ing g = $ARG $ARGV[ V[1] 1]; ; 153. 153. $Sta $Start rtCo Colu lumn mn = $AR $ARGV GV[2 [2]; ]; 154. 154. $End $EndCo Colu lumn mn = $AR $ARGV GV[3 [3]; ]; 155. 155. $Lengt $Length h = $EndCo $EndColum lumn n - $Start $StartCol Column umn + 1; 156. open(MYF open(MYFILE, ILE,$ARG $ARGV[0] V[0]) ) || || die die "Canno "Cannot t open open file \"$ARGV[ \"$ARGV[0]\" 0]\""; "; 157. $i=1; 158. 158. whil while( e($l $lin ine e = ) >) 159. { 160. if( substr($ substr($line line,$St ,$StartC artColum olumn-1, n-1,$Len $Length) gth) =~ /$Search /$SearchStri String/ ng/ ) 161. { 162. 162. prin print t STDO STDOUT UT "$i: "$i: $lin $line" e"; ; 163. } 164. $i++; 165. }
1 66 . DBConnection.pl 1 67 . - Demonstrates: using the "|" operator to pipe output from a system command to a "psuedo-file". 168. 168. #DBC #DBCon onne nect ctio ion. n.pl pl 169. # reads reads a databa database se using using isql on NT NT with with SQLSe SQLServer rver and returns returns info from pubs 170. 170. # 1999 1999/0 /08/ 8/21 21, , mitc mitch h finc finche her r 171. MAIN: 172. { 173. $SelectS $SelectState tatement ment = "SELEC "SELECT T au_lna au_lname,a me,au_fn u_fname, ame,phon phone e FROM FROM autho authors rs "; 174. 174. $DBInf $DBInfo o = "-H mfinc mfincher her -S mfinch mfincher er -d pubs"; pubs"; 175. $SQLComm $SQLCommand and = "isql "isql -Uguest -Uguest -P\"\" -P\"\" $DBIn $DBInfo fo -h-1 -h-1 -s! -w5000 -w5000 -Q\" -Q\" set nocount on $SelectStatement \""; 176. 176. prin print t $SQL $SQLCo Comm mman and d; 177. open(RES open(RESULTS ULTSET, ET, $SQLComm $SQLCommand and ." | ") || || die die "canno "cannot t do a sql sql statement"; 178. $i=1; 179. 179. whil while( e($l $lin ine e = ) >) 180. { 181. chomp($line); 182. $i++; 183. 183. ($au_l ($au_lnam name,$ e,$au au_fn _fname ame,$p ,$phon hone) e) = split split (/\!/, (/\!/,$li $line) ne); ; 184. 184. $au_f au_fna name me =~ s/ //g; //g; 185. 185. $au_l au_lna name me =~ s/ //g; //g; 186. 186. $phone $phone =~ s/[ ]*$//g ]*$//g; ; # remove remove only only traili trailing ng blanks blanks 187. 188. print print "$au_fna "$au_fname me $au_lnam $au_lname\'s e\'s phone phone number number is $phone\n $phone\n"; "; 189. } 190. 190. clos close( e(RE RESU SULT LTS SET); ET); 191. } 192.
5. File Hand Handlling 1. open open a file file for writ writing ing:: 2. 3. 4.
open(OUTFILE, open(OUTFILE, ">temp.out") ">temp.out") || die "Cannot find temp.out"; print OUTFILE "the time has come, the walrus said,...\n"; said,...\n"; clos close e OUTF OUTFIL ILE; E;
5. open open a file file for appen appendin ding: g: 6. open(APP open(APPENDF ENDFILE, ILE, ">> $file $filename name") ") 7. or die "Couldn' "Couldn't t open $filenam $filename e for appendin appending: g: $!";
8. open open a fil filee for for read readin ing: g:
9. open(INF open(INFILE, ILE, "< $filenam $filename") e") 10. 10. or die die "Cou "Could ldn' n't t open open $fil $filen enam ame e for for read readin ing: g: $!";
11. read a whole file into an array array and remove the linefeed linefeed (v5.0): 12.
chomp(@records = );
13. File test operators operators Operator
Meaning
-e $file
File exists
-r $file
File is readable
-w $fil file
File is wr writable ble
-d $f $file
File is is a directory
-f $file
File is a file
14. Ex Exam ample ple:: 15. 15. 16. 17. 18.
if( -f "c:/ "c:/a autoe utoexe xec. c.ba bat" t") ) { print "file exists\n"; }
6. Cont Contro roll Stru Struct ctur ures es:: A. for loop B. C.
for ($i=1 ($i=1; ; $i<10; $i<10;$i+ $i++) +) { prin print t "$i\ "$i\n" n"; ; }
D. While hile loop loop E. F. G. H. I. J.
$j=1; whil while( e($j $j < 10) 10) { prin print t "$j "$j "; $j++; }
K. If-e If-els lsif if-e -els lsee L. M. N. O. P. Q. R. S.
$i=0; if ( $i $i eq eq 0 ) { prin print t "$i "$i = 0"; 0"; } elsi elsif f ( $i eq 2 ) { prin print t "$i "$i = 2"; 2"; } else { print print "$i != 2, $i !=0"; !=0"; }
T. fore foreac ach h loo loop p U. V. W.
@names @names = ("Sarah" ("Sarah", , "Pam", "Pam", "Mitch") "Mitch"); ; foreac foreach h $name $name (@name (@names) s) { print print "$name "$name, , "; }
2. Arra Array y Fun Funct ctio ions ns 1. push - pushes pushes an an eleme element nt onto onto the the end of an array array push (@myarray,$lastvalue) is the same as @myarray = (@myarray,$lastvalue) 2. pop - pops pops the last value value from from an array. array. $valu $valuee = pop(@myar pop(@myarray ray)) 3. unshift unshift - pushe pushess an eleme element nt onto onto the front front of an array array 4. shift shift - pops pops an eleme element nt from from the front front of an array array 5. reverse reverse - reverses reverses the elem elements ents of an array array 6. sort - sorts sorts array array elem elements ents based based on ascii ascii values values 7. chomp chomp - removes removes last last record record separa separator tor from from each each element element 2. Assi Assign gn init initia iall values values to to an array array:: 3. @months = ("January","February", ("January","February","March","Ap "March","April","May"," ril","May","June", June", 4. "July","August","Septem "July","August","September","Octob ber","October","Novembe er","November","Decembe r","December"); r"); 5. or sans sans the the quot quotes, es, 6. @months = qw(January February March April May June
7. July August August Septembe September r October October November November December December); ); 8. 9. to use a specific element prepend it with a "$", like $months[$i]. $months[$i]. 10. 11. 12.
13. 13. misc misc 14. $dir = `dir *.pl`; *.pl`; print print $dir // backtick backtick operator operator 15. 16. perl -e 'srand; 'srand; print print int(rand int(rand(100 (100))' ))' //kinda //kinda random random generato generator r 17. perl -pi.bak -pi.bak -e "s/OLDST "s/OLDSTRING RING/NEW /NEWSTRI STRING/g NG/g" " filelist filelist // substitu substitues es string in files. 18. 19. # to print print a header header to a web browse browser r 20. print print "Conte "Contentnt-typ type: e: text/h text/htm tml\n l\n\n \n 21. print print STDOUT STDOUT "Enter "Enter some some text: text:" " 22. 22. $myt $mytex ext t = N>; ; 23. rename rename oldfi oldfilen lename ame newfil newfilena ename me 24. rename renames s file, file, 1 for succes success, s, 0 otherw otherwise ise 25. 26. 26. to get get fil file e inf info: o: 27. 27. stat stat file fileha hand ndle le 28. example: 29. @files @filestuf tuff f = stat "C:/a "C:/auto utoexe exec.b c.bat" at"; ; 30. print print "filesi "filesize= ze=".@ ".@fil filest estuff uff[7] [7]; ; 31. # how how to show show the the curr current ent date? date? 32. ($sec,$m ($sec,$min,$ in,$hour hour,$md ,$mday,$ ay,$mon, mon,$yea $year,$w r,$wday, day,$yda $yday,$i y,$isdst sdst) ) = localtime(time); 33. ++$mon; ++$mon; # that that wierd wierd month month start start at zero zero thingy thingy 34. print print "$mon "$mon / $mda $mday y / $year" $year"; ; 35. or if if you you want want the the text textual ual month month, , 36. ($sec,$m ($sec,$min,$ in,$hour hour,$md ,$mday,$ ay,$mon, mon,$yea $year,$w r,$wday, day,$yda $yday,$i y,$isdst sdst) ) = localtime(time); 37. @months @months = ("Januar ("January"," y","Febr February uary","M ","March arch","A ","April pril","M ","May", ay","Jun "June", e", 38. "July"," "July","Augu August", st","Sep "Septemb tember", er","Oct "October ober","N ","Novem ovember" ber","De ,"Decemb cember er "); 39. $myDate $myDate = "@{month "@{months[${ s[${mon} mon}]} ]} ${mday}, ${mday}, ${year}" ${year}"; ; 40. 41. to acce access ss comm command and line line argum argument ents: s: 42. $ARGV[0] $ARGV[0] is the the first first arg arg (it skips skips the program program name) name) 43. 43. $ARG $ARGV[ V[1] 1] is is the the seco second nd arg arg 44. $#ARGV $#ARGV is is the coun count t of argum argument ents s minus minus 1 45. 46. 46. Chec Check k for for an argu argume ment nt 47. 47. if(@ if(@AR ARGV GV < 3) 48. { 49. print print "usage: "usage: programn programname ame yada yada yada"; yada"; 50. exit 0; 51. } 52. 53. 54. to create create an array array from from parsin parsing g a string string for separ separator ator token tokens s use "split" 55. Example Example to parse parse the first first input input string string for for ~: ~: 56. @title @titleArr Array ay = split split /~/,$A /~/,$ARGV RGV[0] [0]; ; 57. 58. to get the the leng length th of an array: array: 59. $len $len = scalar scalar(@t (@titl itleAr eArray ray); ); 60. 60. or more more simp simply ly, , 61. 61. $len $len = @tit @title leAr Arra ray; y; 62. 63. 64. to conv conver ert t a stri string ng to to lower lower case case 65. 66. mystring mystring =~ tr/A-Z/ tr/A-Z/a-z/ a-z/; ; #kinda #kinda like like the unix tr command command
67. 68. 68. 69. 69. 70. 70. 71. 72. 73. 74. 74. 75. 76. 77. 77. 78. 79. 79. 80. 80. 81.
bool boolea ean n test tests: s: == != > < : test tests s for for nume numeri rics cs eq ne lt gt : stri string ng
to cre creat ate e a new new dir direc ecto tory ry mkdir("m mkdir("mydir ydir", ", 0755) 0755) || die die "Cannot "Cannot create create direc directory tory mydir mydir: : $!"; prin print t <<' <<'EN ENDO DOFT FTEX EXT' T'; ; any sort of text ext typed yped here here will will be prin printe ted. d. ENDOFTEXT
82. To configure PERL PERL script mapping mapping on web servers for windows windows 98 From some obscure page in the microsoft help database: 1. Star Startt Rege Regedt3 dt32. 2.exe exe and and open open HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\W3SVC\Parameters\ScriptMap 2. Click Click Add Add Val Value ue from from the the Edit Edit menu menu.. 3. Th Thee Val Value ue Name Name is .pl .pl 4. Th Thee Dat Dataa typ typee is is REG REG_SZ _SZ.. 5. The String String value value is exe>\pe \perl. rl.exe exe %s %s 6. Rest Restart art the WWW WWW servic service. e. 83. Subroutine Subroutine to print a file to stdout 84. 84. sub sub prin print_ t_fi file le 85. { 86. 86. loca local l ($my ($myfi file le) ) = @_; @_; 87. 88. open( open(WOR WORDSL DSLIST IST, , $myfil $myfile); e); 89. while while ($name ($name = ) T>) { 90. 90. prin print t "$na "$name me"; "; 91. } 92. 92. clos close( e(WO WORD RDSL SLIS IST) T); ; 93. }
94. Invoke a perl script script from a perl perl script on windows. windows. Remember to put the complete path to perl.exe in front of your perl script. result = system("C:\\Perl\\bin\\perl.exe ReplaceString.pl \"USESAMPLEMGMT=1\" \"USESAMPLEMGMT=0\" $surveyName\\ $surveyName.ini"); result /= 256;
95. Code fragment to change eol char to '', ' | ', read a line and put the characters between between | into an array. This assumes one line in the input file. 96. 97. 98. 98. 99. 100. 101. 102. 102. 103. 104. 105. 105.
$/ = ' | '; $i = 0; whil while( e( E>) ) { ~s/\<\/? ~s/\<\/?t.\> t.\>//g; //g; print print $_."\n"; $_."\n"; if ($_ ne "") { @fields[ @fields[$i] $i] = $_ ; ++$i ++$i; ;
106. } 107. } 108. close(HE close(HEADER ADERFILE FILE); ); 109. 109. $/ = "\n"; "\n"; 110. 110. e> 111. 112. 113. 114.
1 15 . 116. 117. 118. 118. 119. 120. 121. 121. 122. 123. 124. 125. 126.
1 27 .
CGI.pl #!/usr/b #!/usr/bin/p in/perl erl use CGI qw(:stan qw(:standard dard); ); MAIN MAIN: : { $query $query = new CGI; $| = 1; print $query->header('text/p $query->header('text/plain'); lain'); $Name = $query->param('Name'); $query->param('Name'); print print "Hello "Hello $Name"; $Name"; }
Print th the ar arguments pa passed in in us using cg cgi-lib
128. #!/usr/b #!/usr/bin/p in/perl erl 129. # this program just just prints the name-value name-value pairs passed passed to it from a form 130. # mitch finch fincher er 2000/07 2000/07 131. 131. MAIN MAIN: : 132. { 133. require "cgi-lib.pl" || die "Cannot find cgi-lib.pl: $!"; 134. local(*in,$message,$co local(*in,$message,$command); mmand); 135. &ReadPar &ReadParse(* se(*in); in); 136. print print &PrintHe &PrintHeader ader; ; 137. 138. 138. prin print t "\nResults\n" ;\n"; ; 140. print "Submission "Submission From SimpleForm\n SimpleForm\n"; "; 141. print "Variables "Variables passed in:\n"; in:\n"; 142. 143. while ( ($key, $value) = each %in) { 144. print "$key = $value \n"; 145. } 146. print " |