On Fri, Jan 03, 2003 at 06:30:00AM +0100, Peter Lundqvist (disjunkt) @ Pike (-) developers forum wrote:
I'll try to help out in two/three weeks time (if there's anything left ;-)
great! btw. i have asked around in out office, and found two people who have the perl cookbook. this means that i am now able to provide the problem descriptions that the examples are meant to solve.
doing that we can come up with pike examples that are not just copies of the perl code.
the problem descriptions are very short (and i rephrased them and made them even shorter :-) so i may be willing to go through the whole book and provide them. i am certainly willing to provide some on request.
if you want to help, try to come up with various examples that fit the description without looking at the perl code.
here goes the first chapter: 1.5: handle a string one char at a time. 1.6: reverse a string by chars or by words 1.7: convert tabs to spaces if you are not sure that tabs will look right. convert spaces to tabs to make the string smaller. 1.8: evaluate a variable contained inside a string like: "You owe $debt to me." this is not possible in pike, but an example could be made trying to evaluate a shell variable for a system command or a simple example of pike evaluation: you want to value of a variable whose name is contained in a string 1.9: convert upper to lower case and back 1.10: evaluate functioncalls or expressions from a string. typical perl application here, the best i can think of is sprintf, which i always use if i have to mix a lot of text and functioncalls. 1.11: you want to indent text when using #"...", to make your code look more nice, but you don't want that indentation to appear in your string value. (my) solution: stop reading that perl cookbook, it gives you funny ideas. not even in perl i would want to indent the text, because the idea should be, to see the text exactly as it would appear. comment: if you can think of a reason why i am wrong, i am sure you can come up with an example for a solution too :-) 1.12: wordwrapping ling strings to fit a certain line length 1.13: escape certain characters eg % for sprintf... a good place to show the various quoting functions html, mysql, ... 1.14: remove leading or trailing whitespace 1.15: handle csv files with quoted commas and escaped quotes 1.16: match strings according to similar sounds (is there anything for that in pike?) 1.17: program example: this program takes a two column table, and an input string. the words of the first column are replaces with the second in the inputstring (turn the table into a mapping, and apply replace()) 1.18: program example: grep from ps according to your search criteria: % psgrep '/sh\b/' // all lines with "sh" at the end of a word % psgrep 'command =~ /sh$/' // processes with the command ending in "sh" % psgrep 'uid < 10' // processes with a uid below 10 % psgrep 'command =~ /^-/' 'tty ne "?"' // loginshells with active ttys % psgrep 'tty =~ /^[p-t]/' // processes with pseudo ttys % psgrep 'uid && tty eq "?"' // non root without tty % psgrep 'size > 10 * 2**10' 'uid != 0' // huge nonroot processes