Summary

In this chapter, we've reviewed and expanded on all the information you've learned about input and output so far in this book, taking what you already knew about reading from standard input and writing to standard output and using those same techniques to read and write from files.

Files and file handles were the focus of the start of this chapter, and you learned about using the open function to open a file and create a file handle to read from or write to that file. As an adjunct to open you also learned about die, a function that exits the script and prints an error message to the standard error file handle as it goes.

In the next part of the lesson, we talked about script arguments and switches: what happens when you call a script with arguments (they get put into @ARGV) and what you can do to process those arguments. If those arguments includes switches, the best way to process them is with the Getopt::Std module, which lets you define and process, switches to your script, and then tests for the existence of those switches using special variables.

The functions you learned about in this chapter include

  • open, for creating file handles

  • die, for exiting the script with an error message

  • binmode, for setting a file handle to binary mode

  • close, to close a file handle

  • getopts, part of the Getopt module, for declaring and processing arguments

  • getopt, also part of the Getopt module, for handling arguments

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

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