Right now, I feel my typeglob related ignorance is hampering my study of perl.
Don't worry... it probably isn't. ;-)
It is rarely necessary to use typeglobs directly. Especially these days (so long as you use a current version of perl) since support for using lexicals for filehandles has been built into open(). Passing filehandles was once their most common use.
Another use for them that doesn't get as much attention nowadays as I think it should is to create constants. Try the following code for example...
*foo = \"foo";
print "foo is $foo.\n";
$foo = "bar"; # Run time error. Modification of read-only value att
+empted.
I prefer this to use constant FOO => "foo"; since those constants don't interpolate in strings (without jumping through the right hoops.)
I'm not suggesting that you shouldn't learn about them, of course. Only that you probably don't need them. They are indispensable for some introspective tasks and if you are writing a debugger or data dumper or something, you might need them afterall. But, most tasks can (and should) be done without them.
-sauoq
"My two cents aren't worth a dime.";
|