/[pxelator]/lib/PXElator/client.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/client.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 156 - (show annotations)
Thu Aug 6 15:15:53 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 648 byte(s)
implement client::conf to fetch/set (with default) client configuration

1 package client;
2
3 use warnings;
4 use strict;
5 use autodie;
6
7 use server;
8 use File::Slurp;
9
10 sub conf {
11 my $ip = shift;
12 my $name = shift;
13 my ( $default, $value );
14 if ( $#_ == 0 ) {
15 $value = shift;
16 } elsif ( $#_ == 1 && $_[0] eq 'default' ) {
17 $default = $_[1]
18 }
19
20 my $path ="$server::conf/ip/$ip";
21 mkdir $path unless -d $path;
22 $path .= '/' . $name;
23
24 if ( defined $value ) {
25 write_file $path, $value;
26 warn "update $path = $value";
27 } elsif ( ! -e $path && defined $default ) {
28 write_file $path, $default;
29 warn "default $path = $default";
30 $value = $default;
31 } else {
32 $value = read_file $path if -e $path;
33 }
34 return $value;
35 }
36
37 1;

  ViewVC Help
Powered by ViewVC 1.1.26