Exercises

  1. Write a module that generates a frequency count of the letters in a string (number of A’s, B’s, C’s, and so on). The function should return a 256-element array whose index is the character number and whose elements are the number of times that character appears in the string.

  2. Write a module that computes a frequency count of the pairs of letters in a string. Because returning a 256×256 element array is difficult in Perl, you’ll have to create some access functions so that the application can query the counts after you compute them.

    3. Create a module to extract any number of bits from a scalar starting at any offset. For example, the function may be asked to return 5 bits in the string starting at bit index 27.

  3. Write a module that gives a Perl program direct access to the I/O operations (in and out on the PC class machines).

  4. Create a module that allows reading and writing of random bytes in a file. In other words, you can tell this module, “change byte 56 of the file to the letter ‘Q’.”

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset