Input/Output (cont)
Example (a simple cat ):
#!/usr/bin/perl
# Copy stdin to stdout
while ($line = <STDIN>) {
print $line;
}
|
However, this can be simplified to:
while (<STDIN>) { print; }
# or even
print <STDIN>;
|
Defaults:
- the default destination variable for input is
$_
- the default argument for
print is also $_
|