[Israel.pm] simple script question.
Gabor Szabo
gabor at perl.org.il
Sun Sep 26 04:16:00 PDT 2004
On Sun, 26 Sep 2004, Prager, Mark wrote:
> Hi -
> I am trying to get the following short script to work -
>
> #!/usr/local/bin/perl
>
> while (<STDIN>)
> {
> chomp;
> if (/PrintThis/) # if the line contains the word Template - prints out this line, and the next;
> {
> print "$_\n";
> <STDIN>;
> print "$_\n";
> }
> }
the call to <STDIN> puts its result to $_ only by the magic of while()
so when you call it in the middle of the loop <STDIN> reads and discards
the next line.
try replacing it by
my $line = <STDIN>;
print $line;
Gabor
More information about the Perl
mailing list