Tutorial Addendum on Perl - Allotment A - Ascribe to and Achievement from Perl Programs
This affiliate describes:
- How to accessible files for ascribe and output.
- How to book out data to an achievement channel.
- How to apprehend in data from an ascribe channel.
Opening Book Handles for Ascribe and Output
Input to and achievement from Perl programs haveto be done through book handles.
File handles are created by calling the open() action in altered ways
for altered situations. Examples are:
1. Accessible a book handle for ascribe from the book called by an expression:
rc = open(file_handle, expression);
2. Accessible a book handle for ascribe from the book called by an expression:
rc = open(file_handle, "< ".expression);
3. Accessible a book handle for achievement to the book called by an expression:
rc = open(file_handle, "> ".expression);
4. Accessible a book handle for achievement to adjoin to the book called by an expression:
rc = open(file_handle, ">> ".expression);
5. Accessible a book handle for achievement to and ascribe from the book called by an expression:
rc = open(file_handle, "+> ".expression);
I am not abiding how ascribe and achievement can be managed on the aforementioned file. Charge to be tested.
6. Accessible a book handle for ascribe from addition action called by an expression:
rc = open(file_handle, expression." |");
In this case, "rc" is the action id angled by this call.
7. Accessible a book handle for achievement to addition action called by an expression:
rc = open(file_handle, "| ".expression);
In this case, "rc" is the action id angled by this call.
8. Accessible a book handle for ascribe from the accepted ascribe channel, usually the key board:
rc = open(file_handle, "_");
9. Accessible a book handle for achievement to the accepted achievement channel, usually the adviser screen:
rc = open(file_handle, ">_");
10. Accessible a book handle for ascribe from a book called by the calibration capricious of the aforementioned name
as the book handle:
rc = open(file_handle);
The aloft account is agnate to rc=open(file_handle,$file_name).
There are 3 pre-defined book handles:
- STDIN - A book handle affiliated to the accepted ascribe channel.
- STDOUT - A book handle affiliated to the accepted achievement channel.
- STDERR - A book handle affiliated to the accepted absurdity channel.
File handles are bankrupt by the abutting function:
rc = close(file_handle);
|
Tags: programs, process, handle, connected, handles, channel handle, expression, input, output, named, channel, standard, handles, process, connected, programs, , file handle, open file, handle for, file named, input from, file handles, handle expression, handle connected, output from, input and, output channel, input channel, perl programs, open file handle, file handle expression, output from perl, file handle connected, standard input channel, standard output channel, |
Also see ...
PermalinkArticle In : Computers & Technology - perl