STDIN is a file handle (or pointer) and <STDIN> is a scalar representing the next line from the input stream
-
$line = <STDIN>; # sets $line to next line read from standard input
|
Unusually, this line always includes terminating newline and so we have a special function to remove terminating newlines
|
chomp($line); removes the newline in $line and returns a newline (or not, if none is present)
-
$nl = chomp($line) # set $nl to "\n" and remove newline from $line
-
chop is similar but removes any character (not just newline)
|
We can also print scalars with print $line;
|
print is more powerful and we will learn about it later as argument can be a scalar but is normally a list or array
|