Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

  (email not shown publicly)

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Tuesday September 03, 2002
12:37 PM

A filehandle is just a scalar

[ #7500 ]

... or at least, it should be. Currently, a filehandle is a glob. Sort of.

From the point of view of perltie, a filehandle is a thingy that implements TIEHANDLE, WRITE, PRINT, PRINTF, READ, READLINE, GETC, CLOSE, UNTIE, and DESTROY. Or maybe just some of those. In fact, we might distinguish between read-only filehandles, write-only filehandles, and read and write filehandles by the methods implemented.

perltie will let you access that thingy through a tied glob, though, because a filehandle is a glob, more or less. These days, though, a filehandle to me looks like:

open my $fh, $filename or die;

In otherwords, a scalar. I already mentioned three types of filehandles you can have based on the set of methods implemented. What if, in tying a scalar, you had the option to implement some of these filehandle methods? A filehandle would simply be a special kind of scalar. This is where things are supposedly headed in the future, anyway, and it's where most of my code using non-tied filehandles is, now. Moreover, one of the primary uses for globs would go away.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.