/[pxelator]/lib/PXElator/ties.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/PXElator/ties.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 410 - (show annotations)
Wed Sep 9 10:48:59 2009 UTC (14 years, 7 months ago) by dpavlin
File size: 637 byte(s)
split tie scalar into package ties
(which should be called kravata in Croatian :-)

1 package ties;
2
3 use warnings;
4 use strict;
5
6 use File::Slurp;
7 use Data::Dump qw/dump/;
8
9 #use server;
10
11 sub TIESCALAR {
12 my ($class,$name,$default) = @_;
13
14 # my $path = $server::base_dir . '/conf/' . $name; # FIXME we can't call server because it require this package
15 my $path = "/srv/pxelator/conf/$name";
16
17 my $o = {
18 path => $path,
19 };
20 write_file $o->{path}, $default unless -f $o->{path};
21
22 warn "# TIESCALAR $name ", $o->{path}, " [$default]";
23
24 bless \$o,$class;
25 }
26
27 sub STORE {
28 my ( $self, $value ) = @_;
29 write_file $$self->{path}, $value;
30 }
31
32 sub FETCH {
33 my $self = shift;
34 my $v = read_file $$self->{path};
35 chomp($v);
36 $v;
37 }
38
39 1;

  ViewVC Help
Powered by ViewVC 1.1.26