30 |
q( |
q( |
31 |
if (my @infos = $in =~ /^\s*(\S+?):(\S*?):(\S*?):(\S*?):(.*?):(.*?):(.*?)\s*$/) { |
if (my @infos = $in =~ /^\s*(\S+?):(\S*?):(\S*?):(\S*?):(.*?):(.*?):(.*?)\s*$/) { |
32 |
$in = ''; |
$in = ''; |
33 |
$atom->{type} = 'VALUES'; |
$atom->{type} = 'KEY_VALUES'; |
34 |
@{$atom->{values}}{qw(account passwd UID GID GECOS directory shell)} = @infos; |
$atom->{key} = shift @infos; |
35 |
|
@{$atom->{values}}{qw(passwd UID GID GECOS directory shell)} = @infos; |
36 |
$matched = 1; |
$matched = 1; |
37 |
} |
} |
38 |
), |
), |
40 |
comments => [ ['#'] ], |
comments => [ ['#'] ], |
41 |
comment_output => q(/^(\s*)$/ ? "$_\n" : "#$_\n"), |
comment_output => q(/^(\s*)$/ ? "$_\n" : "#$_\n"), |
42 |
output => { |
output => { |
43 |
VALUES => q( |
KEY_VALUES => q( |
44 |
join(':', @{$atom->{values}}{qw(account passwd UID GID GECOS directory shell)}) . "\n"; |
join(':', $atom->{key}, @{$atom->{values}}{qw(account passwd UID GID GECOS directory shell)}) . "\n"; |
45 |
), |
), |
46 |
}, |
}, |
47 |
edit_atom => q( |
edit_atom => q( |
48 |
if ($index == -1) { |
if ($index == -1) { |
49 |
my $i = 0; |
my $i = 0; |
50 |
foreach (@{$out->{atoms}}) { |
foreach (@{$out->{atoms}}) { |
51 |
$_->{values}{account} eq $args{values}{account} and $index = $i; #we don't exit the loop, to have the last atom if multiples ones match |
$_->{key} eq $args{key} and $index = $i; |
52 |
$i++; |
$i++; |
53 |
} |
} |
54 |
$index == -1 and return -2; |
$index == -1 and return -2; |
55 |
} |
} |
61 |
my @res; |
my @res; |
62 |
foreach my $atom (@{$out->{atoms}}) { |
foreach my $atom (@{$out->{atoms}}) { |
63 |
my $flag = 1; |
my $flag = 1; |
64 |
foreach (keys(%args)) { |
foreach my $key (keys(%args)) { |
65 |
$atom->{$_} eq $args{$_} or $flag = 0; |
if ($key eq 'values') { |
66 |
|
foreach (keys(%{$args{values}})) { |
67 |
|
$atom->{values}{$_} eq $args{values}->{$_} or $flag = 0, last; |
68 |
|
} |
69 |
|
} else { |
70 |
|
$atom->{$key} eq $args{$key} or $flag = 0, last; |
71 |
|
} |
72 |
} |
} |
73 |
$flag and push(@res, $i); |
$flag and push(@res, $i); |
74 |
$i++; |
$i++; |