From the course: Perl 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using the OO interface for files

Using the OO interface for files - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

Using the OO interface for files

- [Voiceover] The IO::File module provides an object-oriented interface for the standard file and stream functions. This is the most common way to work with files in Perl. So here's a working copy of iofile.pl from chapter 12 of the exercise files. And you'll notice down here on line 6, I import the IO::File module, and we'll talk about modules a little bit more later on, but this is how you import a module. And with the two colons there, it indicates that the IO::File module is part of a set of modules that share the IO namespace. So down here in line 10, we create our file handle using the IO::File module. And in this case, our file handle is actually referenced to an object. So we have IO::File here with the dereferencing arrow, which is how you access methods and properties inside of a class or an object, and here we're using the class IO::File and the new method as a constructor, to construct this new object. And so the constructor returns the reference, and in the constructor…

Contents