Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • #!/usr/bin/perl -w
    use strict;

    die "Usage: $0 questions.txt [morequestions.txt ...] > answers.txt"
        if not @ARGV;

    while( <> ) {
        print STDERR $_;
        print $_;
        print scalar <STDIN>;
    }

    The key is that the question files must be given as commandline arguments, not passed in via redirection. The <> diamond operator will read from the files listed in @ARGV and you can read STDIN separately from it at the same time.