summaryrefslogtreecommitdiff
path: root/pod/perltie.pod
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-07-15 00:36:22 +0000
committerCharles Bailey <bailey@genetics.upenn.edu>1996-07-15 00:36:22 +0000
commit1f57c600bf2fd9be5af0618189c3cece0cde2c16 (patch)
tree776ceefd2ae70ab084f592a59c8b08ab38484062 /pod/perltie.pod
parent6d28dffb193f5fad8017f93037874bf95b65ec8f (diff)
downloadperl-1f57c600bf2fd9be5af0618189c3cece0cde2c16.tar.gz
perl 5.003_01: pod/perltie.pod
Quote package name in tie -- required when using strict subs Make return value in example meaningful
Diffstat (limited to 'pod/perltie.pod')
-rw-r--r--pod/perltie.pod18
1 files changed, 13 insertions, 5 deletions
diff --git a/pod/perltie.pod b/pod/perltie.pod
index 96f61eb436..658425e7da 100644
--- a/pod/perltie.pod
+++ b/pod/perltie.pod
@@ -192,7 +192,7 @@ take an exception. (Well, if you access an individual element; an
aggregate assignment would be missed.) For example:
require Bounded_Array;
- tie @ary, Bounded_Array, 2;
+ tie @ary, 'Bounded_Array', 2;
$| = 1;
for $i (0 .. 10) {
print "setting index $i: ";
@@ -317,7 +317,7 @@ with the name of the file (minus the dot) and you get back that dotfile's
contents. For example:
use DotFiles;
- tie %dot, DotFiles;
+ tie %dot, 'DotFiles';
if ( $dot{profile} =~ /MANPATH/ ||
$dot{login} =~ /MANPATH/ ||
$dot{cshrc} =~ /MANPATH/ )
@@ -327,7 +327,7 @@ contents. For example:
Or here's another sample of using our tied class:
- tie %him, DotFiles, 'daemon';
+ tie %him, 'DotFiles', 'daemon';
foreach $f ( keys %him ) {
printf "daemon dot file %s is size %d\n",
$f, length $him{$f};
@@ -509,9 +509,17 @@ be careful to check whether they really want to clobber files.
croak "@{[&whowasi]}: won't remove file $file"
unless $self->{CLOBBER};
delete $self->{LIST}->{$dot};
- unlink($file) || carp "@{[&whowasi]}: can't unlink $file: $!";
+ my $success = unlink($file);
+ carp "@{[&whowasi]}: can't unlink $file: $!" unless $success;
+ $success;
}
+The value returned by DELETE becomes the return value of the call
+to delete(). If you want to emulate the normal behavior of delete(),
+you should return whatever FETCH would have returned for this key.
+In this example, we have chosen instead to return a value which tells
+the caller whether the file was successfully deleted.
+
=item CLEAR this
This method is triggered when the whole hash is to be cleared, usually by
@@ -592,7 +600,7 @@ use the each() function to iterate over such. Example:
# print out history file offsets
use NDBM_File;
- tie(%HIST, NDBM_File, '/usr/lib/news/history', 1, 0);
+ tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0);
while (($key,$val) = each %HIST) {
print $key, ' = ', unpack('L',$val), "\n";
}