STDIN is a File Handle or Pointer and <STDIN> is a scalar representing next line from the input stream.
-
$line = <STDIN> sets variable $line to next line read from standard input.
|
Unusually, this line always includes terminating newline and so we have a special function to remove the last character of a string
|
chop($line); removes last character in $line and returns scalar string value of this character
-
$nl = chop($line) # should set $nl to "\n" and remove newline from $line
-
chop is replaced by chomp in Perl5
|
We can also print scalars with print $line;
|
print is more powerful and we learn about it later as argument can be a scalar but is normally a list or array
|