Exercises
Write a subroutine that swaps two arrays.
Write a subroutine that verifies that the argument is a correctly formed integer. For extra credit, give it a flag that lets it check for integers; floating-point numbers (with and without exponents); complex, hexadecimal, and octal numbers; or any combination of these.
Write a module to count the words, lines, and characters in a string.
Write a module to print a hash nicely. Handle the case when the values contain new lines. (For extra credit, handle the case when the value contains unprintable characters.)
Write a function to encode a string so that it may be enclosed in double quotes safely. For example:
becomesThis "string" contains a backslash (\)
"This \"string\" contains a backslash (\\)" ...
Get Perl for C Programmers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.