- or download this
tie VARIABLE, CLASSNAME, LIST - or download this
use Tie::Dir;
tie %hash, Tie::Dir, "./";
- or download this
TIEHASH classname, LIST
DESTROY this
FETCH this, key
...
EXISTS this, key
FIRSTKEY this
NEXTKEY this, lastkey
- or download this
TIEARRAY classname, LIST
DESTROY this
FETCH this, key
STORE this, key, value
- or download this
TIEHANDLE classname, LIST
WRITE this, LIST
PRINT this, LIST
...
GETC this
CLOSE this
DESTROY this
- or download this
# tie %hash, Tie::Dir, ".", DIR_UNLINK;
sub TIEHASH {
...
$unlink ||= 0;
bless [$dir,undef,$unlink], $class;
}
- or download this
sub TIESCALAR {
my $class = shift;
my $name = shift;
...
return bless \$city, $class;
}
- or download this
use Tie::getCity; # If the module name was Tie/getCity.pm
tie($foo, 'Tie::getCity', $ENV{REMOTE_USER});
- or download this
untie $foo; - or download this
package Example;
use strict;
...
sub Version {return $VERSION;}
use Carp;
- or download this
# Create tied hash
sub TIEHASH {
...
return bless $node => $self;
}
- or download this
$hash{FOO} = "bar"; - or download this
# Store an entry
sub STORE {
...
if (!$id && !$passwd) {return 1;}
}
- or download this
$hash{name} = "";
# or
$hash{name} = undef;
- or download this
if ($passwd eq "") {
$cryptedPass = "";
} else {
$cryptedPass = crypt($passwd, $salt);
}
- or download this
# Warning, possible race condition ahead
# I need to update this opening a locking!
...
print FH "$Id\:$cryptedPass\n" unless $cryptedPass eq "";
$foo = $hash{FOO};
}
- or download this
sub FETCH {
my $self = shift;
my $Id = shift;
...
return "$Id doesn't exist";
}
}
- or download this
delete $hash{FOO}; - or download this
sub DELETE {
my $self = shift;
my ($Id) = shift;
...
close FH;
return 1;
}
- or download this
%hash = "";
%hash = %newHash;
%hash = {};
undef %hash;
- or download this
sub CLEAR {
my $self = shift;
my ($passwdFile) = $self->{PATH};
...
close FH;
$self->{CURRENT} = {};
}
- or download this
sub FIRSTKEY {
my $self = shift;
my $a = keys %{$self->{CURRENT}};
each %{$self->{CURRENT}};
}
- or download this
sub NEXTKEY {
my $self = shift;
return each %{$self->{CURRENT}};
}
- or download this
sub DESTROY { unlink "/tmp/tie.txt";} - or download this
#!/usr/bin/perl
use Example;
...
if ($again !~ /y/i) { untie %hash; exit;}else{&ask;}
}
- or download this
tied(%hash)->newPwdFile('/usr/local/apache/.passwds'); - or download this
$obj = tie(%hash, 'Tie::Class', 'rw');
$obj->newPwdFile('/usr/local/apache/.passwds');
- or download this
sub newPwdFile {
my $self = shift;
$self->{PATH} = @_ ? shift : die "No new file given";
...
}
}
- or download this
# Usage: tie($VARIABLE,'TrackScalar', FILE, "\$VARIABLE name/descr
+iption");
# use TrackScalar;
...
}
1;