Differences between version 2 and previous revision of perltie(1).
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 2 | Last edited on Tuesday, June 4, 2002 12:22:39 am | by perry | Revert |
Older page: | version 1 | Last edited on Tuesday, June 4, 2002 12:22:39 am | by perry | Revert |
@@ -233,16 +233,16 @@
element larger than the fixed size, you'll take an
exception. For example:
- use FixedElem_Array;
-tie @array, 'FixedElem_Array', 3;
+ use !
FixedElem_Array;
+tie @array, '!
FixedElem_Array', 3;
$array[[0] = 'cat'; # ok.
$array[[1] = 'dogs'; # exception, length('dogs')
The preamble code for the class is as follows:
- package FixedElem_Array;
+ package !
FixedElem_Array;
use Carp;
use strict;
TIEARRAY classname, LIST
@@ -566,22 +566,22 @@
(minus the dot) and you get back that dot file's contents.
For example:
- use DotFiles;
-tie %dot, 'DotFiles';
+ use !
DotFiles;
+tie %dot, '!
DotFiles';
if ( $dot{profile} =~ /MANPATH/
$dot{login} =~ /MANPATH/
$dot{cshrc} =~ /MANPATH/ )
{
print
Or here's another sample of using our tied class:
- tie %him, 'DotFiles', 'daemon';
+ tie %him, '!
DotFiles', 'daemon';
foreach $f ( keys %him ) {
printf
-In our tied hash DotFiles example, we use a regular hash for the object containing several important fields, of which only the {LIST} field will be what the user thinks of as the real hash.
+In our tied hash !
DotFiles example, we use a regular hash for the object containing several important fields, of which only the {LIST} field will be what the user thinks of as the real hash.
USER
@@ -610,17 +610,17 @@
Here's the start of ''Dotfiles.pm'':
- package DotFiles;
+ package !
DotFiles;
use Carp;
sub whowasi { (caller(1))[[3] . '()' }
my $DEBUG = 0;
sub debug { $DEBUG = @_ ? shift : 1 }
For our example, we want to be able to emit debugging info to help in tracing during development. We keep also one convenience function around internally to help print out warnings; ''whowasi()'' returns the function name that calls it.
-Here are the methods for the DotFiles tied
+Here are the methods for the !
DotFiles tied
hash.
TIEHASH classname,
@@ -654,9 +654,9 @@
its self reference: the key whose value we're trying to
fetch.
-Here's the fetch for our DotFiles example.
+Here's the fetch for our !
DotFiles example.
sub FETCH {
carp
@@ -674,9 +674,9 @@
something, and the value we're trying to put
there.
-Here in our DotFiles example, we'll be careful not to let
+Here in our !
DotFiles example, we'll be careful not to let
them try to overwrite the file unless they've called the
''clobber()'' method on the original object reference
returned by ''tie()''.
@@ -815,9 +815,9 @@
while (($key,$val) = each %HIST) {
print $key, ' = ', unpack('L',$val),
-__Tying FileHandles__
+__Tying !
FileHandles__
This is partially implemented now.