Input/output streams

So far, our application has only printed the returned results to our screen, which is standard output, or STDOUT. Next, we will take a look at how we can log the output easily from our Perl program into a file using the shell redirect operators > and >>. These operators behave in a similar fashion to how they are used in the Perl open() function for opening a file for writing. We will also learn how to redirect STDOUT into STDIN, or the standard input of another application as arguments.

Tip

Guess what? Our screen is also a file! In the directory /dev/ in most Linux distributions, there is a file called stdout, which we can echo strings into or even redirect a command into, and the output is returned from the file descriptor ...

Get Penetration Testing with Perl now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.