Help for this page

Select Code to Download


  1. or download this
    $ echo foo > foo.txt
    
    ...
    
    $ perl -e'open FILE, $ARGV[0] or die $!; print <FILE>' 'cat foo.txt |'
    foo
    
  2. or download this
    $ echo foo | perl -e'@ARGV = "-" if !@ARGV; open FILE, $ARGV[0] or die
    + $!; print <FILE>'
    foo
    
  3. or download this
    $ perl -e'print <>' foo.txt
    foo
    ...
    
    $ perl -e'print <>' 'cat foo.txt |'
    foo
    
  4. or download this
    *FILE = *STDIN;
    $fh   = *STDIN;
    $fh   = \*STDIN;    # Ref often allowed and even preferred.