Perl has a number of built-in functions that can manipulate the filesystem

The file input and output functions

The directory-manipulation functions

The file-attribut manipulation functions

The DBM file functions

File Input and Output Functions

Opening Pipes

Two commands can be linked using a pipe. The first commands standard output is piped (linked) to the second connads standard input. To do this we need to associate the file with the command by calling open.

Opening pipe example
(output)

open (MESAAGE, "| mail paul.valle@datadisk.co.uk");
print MESSAGE ("Hello how is the website coming along?");
close (MESSAGE);

Note: The call to open establishes a pipe to the command "mail paul.valle@datadisk.co.uk", the file variable MESSAGE is now associated with this pipe. The call to print add the line to the message to be sent. The call to close closes the pipe and the mail program can then send the mail message.

Opening pipe example
(input)

open (CAT, "cat file*|");
$input = <CAT>; ## variable input will now have the cat'ed contents of all the files

Redirecting One File to Another

Unix allows you to direct both the standard outfile file and the standard error file to the same output file. You can also perform the same task with Perl