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?
Figure 5-1. Preparing to enter the command make_exhibit.plx | more
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 ...
Get Perl for Web Site Management 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.