I piping the output of several scripts. One of these scripts outputs an entire HTML page that gets processed by my perl script. I want to be able to pull the whole 58K of text into the perl script (which will contain newlines, of course).
I thought this might work:
open(my $TTY, '<', '/dev/tty');
my $html_string= do { local( @ARGV, $/ ) = $TTY ; <> } ;
But it just isn't doing what I need. Any suggestions?
STDIN in Scalar Context In order to take input from the keyboard or operator is used in Perl. This operator reads a line entered through the keyboard along with the newline character corresponding to the ENTER we press after input.
Input to a Perl program can be given by keyboard with the use of <STDIN>. Here, STDIN stands for Standard Input .
The most commonly used special variable is $_, which contains the default input and pattern-searching string. For example, in the following lines − #!/usr/bin/perl foreach ('hickory','dickory','doc') { print $_; print "\n"; }
my @lines = <STDIN>;
or
my $str = do { local $/; <STDIN> };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With