O'Reilly logo

Perl for Web Site Management by John Callender

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Outputting Sample Data

It’s time to run this first version of the script to find out how it does in parsing the exhibitor.txt data file:

[jbc@andros sprocketexpo]$ make_exhibit.plx | more

Figure 5-1 shows our ssh window just before we enter the command, and Figure 5-2 shows the window just after we enter the command. Strangely, even though we’re piping the command to more (which is supposed to stop the output at one screenful), we get more than a screenful of text appearing in our window. The text scrolls by so fast that we can’t read the first part. What’s going on?

Preparing to enter the command make_exhibit.plx | more

Figure 5-1. Preparing to enter the command make_exhibit.plx | more

After entering the command shown in Figure 5-1, several lines of error output scroll off the top of the terminal window before more pauses the output

Figure 5-2. After entering the command shown in Figure 5-1, several lines of error output scroll off the top of the terminal window before more pauses the output

What’s going on is that reality is more complex than the mental model we were using. In brief, both the script’s warnings and its conventional output are printed to our window, but the more command only sees the part that prints to standard output (the part from the print statements in the script). As a result, it pauses that output too late for us to see the stuff being printed to standard error (the part from the warn statements in the script). Fun with Output Streams explains how to use a little ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required