Mega Code Archive

 
Categories / Perl / File
 

Open command expressions

EXPRESSION                       EFFECT open (FH, "<filename")           Opens file name for reading. open (FH, "+<filename")          Opens file name for both reading and writing. open (FH, ">filename")           Opens file name for writing. open (FH, "+>filename")          Opens file name for both reading and writing. open (FH, ">>filename")          Opens file name for appending. open (FH, "command|")            Runs the command and pipes its output to the filehandle. open (FH, "|command")            Pipes the output along the filehandle to the command. open (FH, "-")                   Opens STDIN. open (FH, ">-")                  Opens STDOUT. open (FH, "<&=N")                Where N is a number, this performs the equivalent of C's fdopen for reading. open (FH, ">&=N")                Where N is a number, this performs the equivalent of C's fdopen for writing.