annotate Lib/IMPL/lang.pm @ 389:5aff94ba842f

DOM Schema refactoring complete
author cin
date Wed, 12 Feb 2014 13:36:24 +0400
parents d5c8b955bf8d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
164
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
1 package IMPL::lang;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
2 use strict;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
3 use warnings;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
4
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
5 use parent qw(Exporter);
164
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
6 use IMPL::_core::version;
173
aaab45153411 minor bugfixes
sourcer
parents: 169
diff changeset
7 use IMPL::clone qw(clone);
274
8d36073411b1 +Added AutoDispose class
cin
parents: 271
diff changeset
8 use Scalar::Util qw(blessed);
280
c6d0f889ef87 +IMPL::declare now supports meta attributes
cin
parents: 278
diff changeset
9 use Carp qw(carp);
164
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
10
274
8d36073411b1 +Added AutoDispose class
cin
parents: 271
diff changeset
11 our @EXPORT = qw(&is &isclass &typeof);
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
12 our %EXPORT_TAGS = (
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
13 base => [
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
14 qw(
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
15 &is
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
16 &clone
271
56364d0c4b4f +IMPL::SQL::Schema::MySQL: added basic support for MySQL
cin
parents: 241
diff changeset
17 &isclass
274
8d36073411b1 +Added AutoDispose class
cin
parents: 271
diff changeset
18 &typeof
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
19 )
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
20 ],
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
21
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
22 declare => [
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
23 qw(
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
24 &public
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
25 &protected
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
26 &private
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
27 &property
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
28 &static
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
29 &property
278
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
30 &_direct
213
sergey
parents: 210
diff changeset
31 &ACCESS_PUBLIC
sergey
parents: 210
diff changeset
32 &ACCESS_PROTECTED
sergey
parents: 210
diff changeset
33 &ACCESS_PRIVATE
sergey
parents: 210
diff changeset
34 &PROP_GET
sergey
parents: 210
diff changeset
35 &PROP_SET
sergey
parents: 210
diff changeset
36 &PROP_OWNERSET
sergey
parents: 210
diff changeset
37 &PROP_LIST
sergey
parents: 210
diff changeset
38 &PROP_ALL
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 213
diff changeset
39 &PROP_RO
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 213
diff changeset
40 &PROP_RW
278
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
41 &PROP_DIRECT
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
42 )
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
43 ],
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
44 compare => [
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
45 qw(
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
46 &equals
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
47 &equals_s
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
48 &hashCompare
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
49 )
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
50 ],
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
51 hash => [
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
52 qw(
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
53 &hashApply
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
54 &hashMerge
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
55 &hashDiff
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
56 &hashCompare
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
57 &hashParse
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
58 &hashSave
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
59 )
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
60 ]
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
61 );
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
62
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
63 our @EXPORT_OK = keys %{ { map (($_,1) , map (@{$_}, values %EXPORT_TAGS) ) } };
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
64
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 213
diff changeset
65 use IMPL::Const qw(:all);
164
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
66
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
67 sub is($$) {
280
c6d0f889ef87 +IMPL::declare now supports meta attributes
cin
parents: 278
diff changeset
68 carp "A typename can't be undefined" unless $_[1];
371
d5c8b955bf8d refactoring
cin
parents: 315
diff changeset
69 blessed($_[0]) and $_[0]->isa( $_[1] );
271
56364d0c4b4f +IMPL::SQL::Schema::MySQL: added basic support for MySQL
cin
parents: 241
diff changeset
70 }
56364d0c4b4f +IMPL::SQL::Schema::MySQL: added basic support for MySQL
cin
parents: 241
diff changeset
71
56364d0c4b4f +IMPL::SQL::Schema::MySQL: added basic support for MySQL
cin
parents: 241
diff changeset
72 sub isclass {
280
c6d0f889ef87 +IMPL::declare now supports meta attributes
cin
parents: 278
diff changeset
73 carp "A typename can't be undefined" unless $_[1];
371
d5c8b955bf8d refactoring
cin
parents: 315
diff changeset
74 local $@;
271
56364d0c4b4f +IMPL::SQL::Schema::MySQL: added basic support for MySQL
cin
parents: 241
diff changeset
75 eval {not ref $_[0] and $_[0]->isa( $_[1] ) };
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
76 }
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
77
274
8d36073411b1 +Added AutoDispose class
cin
parents: 271
diff changeset
78 sub typeof(*) {
371
d5c8b955bf8d refactoring
cin
parents: 315
diff changeset
79 local $@;
315
77df11605d3a code cleanup
cin
parents: 280
diff changeset
80 eval { $_[0]->_typeof } || blessed($_[0]) || ref($_[0]);
274
8d36073411b1 +Added AutoDispose class
cin
parents: 271
diff changeset
81 }
8d36073411b1 +Added AutoDispose class
cin
parents: 271
diff changeset
82
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
83 sub public($) {
278
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
84 my $info = shift;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
85 $info->{access} = ACCESS_PUBLIC;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
86 my $implementor = delete $info->{implementor};
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
87 $implementor->Implement($info);
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
88 }
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
89
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
90 sub private($) {
278
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
91 my $info = shift;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
92 $info->{access} = ACCESS_PRIVATE;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
93 my $implementor = delete $info->{implementor};
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
94 $implementor->Implement($info);
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
95 }
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
96
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
97 sub protected($) {
278
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
98 my $info = shift;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
99 $info->{access} = ACCESS_PROTECTED;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
100 my $implementor = delete $info->{implementor};
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
101 $implementor->Implement($info);
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
102 }
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
103
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
104 sub _direct ($) {
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
105 my $info = shift;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
106 $info->{direct} = 1;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
107 return $info;
164
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
108 }
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
109
278
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
110 sub property($$) {
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
111 my ($propName,$attributes) = @_;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
112
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
113 $attributes = {
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
114 get => $attributes & PROP_GET,
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
115 set => $attributes & PROP_SET,
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
116 isList => $attributes & PROP_LIST
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
117 } unless ref $attributes;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
118
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
119 my $class = caller;
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
120
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
121 return hashMerge (
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
122 $attributes,
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
123 {
278
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
124 implementor => $class->ClassPropertyImplementor,
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
125 name => $propName,
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
126 class => scalar(caller),
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
127 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
128 );
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
129 }
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
130
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
131 sub static($$) {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
132 my ( $name, $value ) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
133 my $class = caller;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
134 $class->static_accessor( $name, $value );
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
135 }
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
136
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
137 sub equals {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
138 if (defined $_[0]) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
139 return 0 if (not defined $_[1]);
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
140
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
141 return $_[0] == $_[1];
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
142 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
143 return 0 if defined $_[1];
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
144
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
145 return 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
146 }
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
147 }
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
148
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
149 sub equals_s {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
150 if (defined $_[0]) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
151 return 0 if (not defined $_[1]);
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
152
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
153 return $_[0] eq $_[1];
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
154 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
155 return 0 if defined $_[1];
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
156
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
157 return 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
158 }
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
159 }
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
160
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
161 sub hashDiff {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
162 my ($src,$dst) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
163
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
164 $dst = $dst ? { %$dst } : {} ;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
165 $src ||= {};
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
166
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
167 my %result;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
168
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
169 foreach my $key ( keys %$src ) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
170 if (exists $dst->{$key}) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
171 $result{"+$key"} = $dst->{$key} unless equals_s($dst->{$key}, $src->{$key});
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
172 delete $dst->{$key};
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
173 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
174 $result{"-$key"} = 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
175 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
176 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
177
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
178 $result{"+$_"} = $dst->{$_} foreach keys %$dst;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
179
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
180 return \%result;
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
181 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
182
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
183 sub hashMerge {
210
6adaeb86945d added IMPL::Web::AutoLocator
sergey
parents: 194
diff changeset
184 return hashApply( { %{$_[0] || {}} }, $_[1] );
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
185 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
186
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
187 sub hashApply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
188 my ($target,$diff) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
189
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 230
diff changeset
190 return $target unless ref $diff eq 'HASH';
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 230
diff changeset
191
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
192 while ( my ($key,$value) = each %$diff) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
193 $key =~ /^(\+|-)?(.*)$/;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
194 my $op = $1 || '+';
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
195 $key = $2;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
196
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
197 if ($op eq '-') {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
198 delete $target->{$key};
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
199 } else {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
200 $target->{$key} = $value;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
201 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
202 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
203
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
204 return $target;
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
205 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
206
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
207 sub hashCompare {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
208 my ($l,$r,$cmp) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
209
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
210 $cmp ||= \&equals_s;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
211
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
212 return 0 unless scalar keys %$l == scalar keys %$r;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
213 &$cmp($l->{$_},$r->{$_}) || return 0 foreach keys %$l;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
214
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
215 return 1;
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
216 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
217
174
d920d2b70230 minor changes
sergey
parents: 173
diff changeset
218 sub hashParse {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
219 my ($s,$p,$d) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
220
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
221 $p = $p ? qr/$p/ : qr/\n+/;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
222 $d = $d ? qr/$d/ : qr/\s*=\s*/;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
223
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
224 return {
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
225 map split($d,$_,2), split($p,$s)
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
226 };
174
d920d2b70230 minor changes
sergey
parents: 173
diff changeset
227 }
d920d2b70230 minor changes
sergey
parents: 173
diff changeset
228
d920d2b70230 minor changes
sergey
parents: 173
diff changeset
229 sub hashSave {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
230 my ($hash,$p,$d) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
231
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
232 return "" unless ref $hash eq 'HASH';
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
233
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
234 $p ||= "\n";
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
235 $d ||= " = ";
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
236
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
237 return
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
238 join(
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
239 $p,
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
240 map(
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
241 join(
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
242 $d,
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
243 $_,
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
244 $hash->{$_}
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
245 ),
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
246 keys %$hash
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
247 )
4d0e1962161c Replaced tabs with spaces
cin
parents: 181
diff changeset
248 );
174
d920d2b70230 minor changes
sergey
parents: 173
diff changeset
249 }
d920d2b70230 minor changes
sergey
parents: 173
diff changeset
250
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
251 1;