Venerable Variables:- passVariables: take an variable, and put it's reference into another variable, and then print out the value.
Messing with Arrays:
- passArray:
Make an array in one subroutine, and pass it to another subroutine.
Then separate out the variables in the array with commas and print.
- passArrayOfArray: make a 2d array, pass it to another subroutine, and separate the variables of each array with colons and print
- copyFileToAofA:
enter in a file that is tab deliminated, this script will break apart
the tab deliminated cells, and convert each cell to variables. From all
that it will create an array of arrays (2D array) and pass it to
another subroutine that will print out all the variables with colon's in between.
- RefOfArrays: ways you can use references of arrays.
- Arrays to Lists: what happens when you try and convert an array to a list.
- ref/unref-ing Arrays: how to reference arrays and get them back
- transposeArray: How to rotate a matrix
- transposeArray2: Use the transpose method to convert columns in a spreadsheet into separate sheets
- grabnPrint: In one sub open a file and put into an array, pass the reference of the array to another sub and do stuff
Flailing around with Hashes:
- matchHashes-a+b:
take two hash tables; a and b. make a new hash table that is the
combined value of the two. If a and b have the same variables, use the
value of the variable in the b hash as the value for the new hash
table.
- matchHashes-a_with_b_values:
here we take the two hashes a and b, and add values from b to a IF the
variable exists in a. Thus the output has only the items from a, but if
b had the same item, then we get b's value for that idem overwritten
over a.
- StringHashes: with two hashs, one is the key for the other, and string them together
- passHash:
make two different hashes, in one make a normal hash and pass it out of
a sub, in the other make an anonymous hash and pass it out of the
subroutine. (they both end up being anonymous after they are passed out
of the sub. Then accept it into another sub and print two ways; one in
an OO way, and the other has a more normal looking code way of doing
it.
- passHash2: Create a hash, and run two different subroutines that add to the hash. Do this by passing references to a hash around.
- copyFileToHash:
Take a tab deliminated text file, and convert it into a hash table.
Then pass the reference for that hash table to another subroutine and
print out the hash table.
- passArraytoHash:
take an array, stick it into a hash, then erase the contents of the
array and refill it up with something different, and then stick the new
value into the array. (thus making a long list of arrays). Then print
everything out.
Ogling over OO:
- Making and Referencing Modules: Discusses how to create a module and how to link to it. (less of a code example, and more of a how-to)
- Extending the library path: Perl Modules normally have to go in very specific places. This tells you want to do if you want to store them someplace else.
Opening/Printing Stuff
- doOrDie: Open a file and properly exit if the file is not there.
- listDir: Look at a directory via perl, and print it out.
- listDirViaOpen: Look at a directory by running a shell command within perl, and print results.
- readInFile: Open a file in one subroutine, then print it out within another.
- usage: All scripts should have usage statements, here's an example for how to do this.
Mod_perl:- readGET: grab a variable in the uri, and present it on the page
- uriVars: how to feed in multiple variables in a uri
- listDir2: Look at a directory and print it out.
- AutoHTML: using CGI:: to automatically enter in your html headers
- FormSubmit: provide a form, submit it and do action against it.
Random tools and functions
- Time: uses the localtime function to come up with date, time, second information.
- Code2HTML: tool that converts perl script to color coded html. Used in these pages to document code. There is also tohtml
Other Code ExamplesOther stuff that is not worth using as examples, but needs a place to be kept.
|
|