I have been learning perl, and find the motto interesting. It says there are multiple ways of doing anything. I know that you can use print
and say
to output stuff, but I haven't found any other way to read input than to use a predefined file pointer-like thing.
Are there any other ways?
This question is too broad.
There are many different ways to read from a handle:
<>
/readline
(with $/ = $line_ending;
)<>
/readline
(with $/ = undef;
)<>
/readline
(with $/ = \$block_size;
)<>
/readline
(with $/ = "";
)getc
read
sysread
Then there are tools to work with terminals.
Also, handles can be represented in multiple ways.
*STDIN{IO}
)*STDIN
)\*STDIN
)'STDIN'
)In one-liners, -n
, -p
, -l
, -0
, -F
, -a
and -C
all have some connection to STDIN.
...