Standard Input / Output
Standard output
Functions
print
print STRING # Print a string to standard output
print STDOUT STRING # Print a string to standard output (same as above)
print NUMBER # Print a number to standard output
print "Hello, world!\n";
print 42;
print; # Prints $_ by default.
print $str;
print $arr[0];
print "one two $str_three";
print "The value of $key is $hash{$key}\n";
print <<LABEL;
...any text can go here...
LABEL
Standard input
- The string read in includes the newline character
Functions
<STDIN>
- Read from standard input
$data = <STDIN>;
Standard error
- Normally, standard error prints to the screen
Functions
print STDERR STRING # Print a string to standard error
print STDERR NUMBER # Print a number to standard error
print STDERR $err_msg;
print STDERR "Error number: $error_num";
Resources URL:
notes/perl/resources
Sources URL:
notes/perl/sources