ADBRITE ads links
You are here: CodeIdol.com > Perl > Intermediate Perl > Filehandle References
Intermediate Perl
| 8.1. The Old Way
In the olden days, Perl used barewords for
filehandle names. The filehandle is another Perl data type, although people don't talk about it too much since it doesn't get its own special sigil. You've probably already seen a l...
|
|
| 8.2. The Improved Way
Starting with Perl 5.6, open can create a filehandle reference in a normal scalar variable. Instead of using a bareword for the filehandle name, we use a scalar variable whose value is undef.
my $log_f...
|
|
| 8.3. The Even Better Way
So far, our examples have shown the two-argument form of open, but that actually has a catch: the open mode and the filename both live in the second argument. That means that we have to store two different things ...
|
|
| 8.4. IO::Handle
Behind the scenes, Perl is really using the IO::Handle module to work this magic, so our filehandle scalar is really an object.[*] The IO::Handle package is a base class for input-output things, so it handles a lot more than just f...
|
|
| 8.5. Directory Handle References
In the same way that we can create references to filehandles, we can create directory handle references.
opendir my $dh, '.' or die "Could not open directory: $!";
foreach my $file ( readdir( $dh...
|
|
| 8.6. Exercises
You can find the answers to these exercises in "Answers for Chapter 8" in the Appendix.
8.6.1. Exercise 1 [20 min]
Write a program that prints the date and the day of the week, but allow the user to choose to send the output eit...
|
|
You are here: CodeIdol.com > Perl > Intermediate Perl > Filehandle References
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|