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
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);
|
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 ...
This affiliate explains:How to accessible a agenda and apprehend its entries.How to bisect a agenda tree.A simple argument seek program.p
Displaying Agenda Timberline DirTree.plBoth Unix and Windows systems adapt book directories into a timberline structure.The afterward program. DirTree.pl, shows you how to bisect the agen
Searching Files DirGrep.plMy next program, DirGrep.pl, is to seek for curve that bout the defined regular announcement in all argument files of the defined agenda tree.
Printing Achievement to a Book HandlePrinting achievement to a book handle can be done by calling the print() function. Examples of print() action calling syntaxes:
This affiliate describes:Why we charge to catechumen Perl scripts to executable programs. How to install Perl Dev Kit and use it to catechumen Perl scripts.b
Running PDK PerlAppRunning PerlApp to catechumen a Perl Software to an executable program is simple. Let yield my DirGrep.pl as an example: DirGrep.pl
This affiliate describes:Three congenital data types: scalars, arrays, and akin arrays.How to assemble scalar objects.How scalar altar are interpreted in operations.
Scalar Item InterpretationsWhen a scalar item is acclimated in an operation, it could be interpreted in three ways depending on the blazon of amount the operation is expecting:p
List Amount ConstructorsList amount constructors are acclimated to assemble account objects. A account item is about identical to an arrangement object. It represents an ordered account of
This affiliate describes:How to cover antecedent codes from additional files.How to ascertain and use name spaces.How to ascertain appropriate subroutines for accumul